Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(467)

Side by Side Diff: src/mips/code-stubs-mips.cc

Issue 10107025: MIPS: Make SubStringStub more robust with unsafe arguments. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 6077 matching lines...) Expand 10 before | Expand all | Expand 10 after
6088 __ And(t0, a1, Operand(kIsNotStringMask)); 6088 __ And(t0, a1, Operand(kIsNotStringMask));
6089 6089
6090 __ Branch(&runtime, ne, t0, Operand(zero_reg)); 6090 __ Branch(&runtime, ne, t0, Operand(zero_reg));
6091 6091
6092 // Short-cut for the case of trivial substring. 6092 // Short-cut for the case of trivial substring.
6093 Label return_v0; 6093 Label return_v0;
6094 // v0: original string 6094 // v0: original string
6095 // a2: result string length 6095 // a2: result string length
6096 __ lw(t0, FieldMemOperand(v0, String::kLengthOffset)); 6096 __ lw(t0, FieldMemOperand(v0, String::kLengthOffset));
6097 __ sra(t0, t0, 1); 6097 __ sra(t0, t0, 1);
6098 // Return original string.
6098 __ Branch(&return_v0, eq, a2, Operand(t0)); 6099 __ Branch(&return_v0, eq, a2, Operand(t0));
6099 6100 // Longer than original string's length or negative: unsafe arguments.
6100 6101 __ Branch(&runtime, hi, a2, Operand(t0));
6101 Label result_longer_than_two; 6102 // Shorter than original string's length: an actual substring.
6102 // Check for special case of two character ASCII string, in which case
6103 // we do a lookup in the symbol table first.
6104 __ li(t0, 2);
6105 __ Branch(&result_longer_than_two, gt, a2, Operand(t0));
6106 __ Branch(&runtime, lt, a2, Operand(t0));
6107
6108 __ JumpIfInstanceTypeIsNotSequentialAscii(a1, a1, &runtime);
6109
6110 // Get the two characters forming the sub string.
6111 __ Addu(v0, v0, Operand(a3));
6112 __ lbu(a3, FieldMemOperand(v0, SeqAsciiString::kHeaderSize));
6113 __ lbu(t0, FieldMemOperand(v0, SeqAsciiString::kHeaderSize + 1));
6114
6115 // Try to lookup two character string in symbol table.
6116 Label make_two_character_string;
6117 StringHelper::GenerateTwoCharacterSymbolTableProbe(
6118 masm, a3, t0, a1, t1, t2, t3, t4, &make_two_character_string);
6119 __ jmp(&return_v0);
6120
6121 // a2: result string length.
6122 // a3: two characters combined into halfword in little endian byte order.
6123 __ bind(&make_two_character_string);
6124 __ AllocateAsciiString(v0, a2, t0, t1, t4, &runtime);
6125 __ sh(a3, FieldMemOperand(v0, SeqAsciiString::kHeaderSize));
6126 __ jmp(&return_v0);
6127
6128 __ bind(&result_longer_than_two);
6129 6103
6130 // Deal with different string types: update the index if necessary 6104 // Deal with different string types: update the index if necessary
6131 // and put the underlying string into t1. 6105 // and put the underlying string into t1.
6132 // v0: original string 6106 // v0: original string
6133 // a1: instance type 6107 // a1: instance type
6134 // a2: length 6108 // a2: length
6135 // a3: from index (untagged) 6109 // a3: from index (untagged)
6136 Label underlying_unpacked, sliced_string, seq_or_external_string; 6110 Label underlying_unpacked, sliced_string, seq_or_external_string;
6137 // If the string is not indirect, it can only be sequential or external. 6111 // If the string is not indirect, it can only be sequential or external.
6138 STATIC_ASSERT(kIsIndirectStringMask == (kSlicedStringTag & kConsStringTag)); 6112 STATIC_ASSERT(kIsIndirectStringMask == (kSlicedStringTag & kConsStringTag));
(...skipping 1550 matching lines...) Expand 10 before | Expand all | Expand 10 after
7689 __ Ret(USE_DELAY_SLOT); 7663 __ Ret(USE_DELAY_SLOT);
7690 __ mov(v0, a0); 7664 __ mov(v0, a0);
7691 } 7665 }
7692 7666
7693 7667
7694 #undef __ 7668 #undef __
7695 7669
7696 } } // namespace v8::internal 7670 } } // namespace v8::internal
7697 7671
7698 #endif // V8_TARGET_ARCH_MIPS 7672 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698