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

Side by Side Diff: src/x64/lithium-codegen-x64.cc

Issue 7477045: Tentative implementation of string slices (hidden under the flag --string-slices). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Support for RegExp. Removed methods related to truncate. Created 9 years, 4 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
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 3130 matching lines...) Expand 10 before | Expand all | Expand 10 after
3141 public: 3141 public:
3142 DeferredStringCharCodeAt(LCodeGen* codegen, LStringCharCodeAt* instr) 3142 DeferredStringCharCodeAt(LCodeGen* codegen, LStringCharCodeAt* instr)
3143 : LDeferredCode(codegen), instr_(instr) { } 3143 : LDeferredCode(codegen), instr_(instr) { }
3144 virtual void Generate() { codegen()->DoDeferredStringCharCodeAt(instr_); } 3144 virtual void Generate() { codegen()->DoDeferredStringCharCodeAt(instr_); }
3145 private: 3145 private:
3146 LStringCharCodeAt* instr_; 3146 LStringCharCodeAt* instr_;
3147 }; 3147 };
3148 3148
3149 Register string = ToRegister(instr->string()); 3149 Register string = ToRegister(instr->string());
3150 Register index = no_reg; 3150 Register index = no_reg;
3151 Register offset = ToRegister(instr->TempAt(0));
3151 int const_index = -1; 3152 int const_index = -1;
3152 if (instr->index()->IsConstantOperand()) { 3153 if (instr->index()->IsConstantOperand()) {
3153 const_index = ToInteger32(LConstantOperand::cast(instr->index())); 3154 const_index = ToInteger32(LConstantOperand::cast(instr->index()));
3154 STATIC_ASSERT(String::kMaxLength <= Smi::kMaxValue); 3155 STATIC_ASSERT(String::kMaxLength <= Smi::kMaxValue);
3155 if (!Smi::IsValid(const_index)) { 3156 if (!Smi::IsValid(const_index)) {
3156 // Guaranteed to be out of bounds because of the assert above. 3157 // Guaranteed to be out of bounds because of the assert above.
3157 // So the bounds check that must dominate this instruction must 3158 // So the bounds check that must dominate this instruction must
3158 // have deoptimized already. 3159 // have deoptimized already.
3159 if (FLAG_debug_code) { 3160 if (FLAG_debug_code) {
3160 __ Abort("StringCharCodeAt: out of bounds index."); 3161 __ Abort("StringCharCodeAt: out of bounds index.");
3161 } 3162 }
3162 // No code needs to be generated. 3163 // No code needs to be generated.
3163 return; 3164 return;
3164 } 3165 }
3165 } else { 3166 } else {
3166 index = ToRegister(instr->index()); 3167 index = ToRegister(instr->index());
3167 } 3168 }
3168 Register result = ToRegister(instr->result()); 3169 Register result = ToRegister(instr->result());
3169 3170
3170 DeferredStringCharCodeAt* deferred = 3171 DeferredStringCharCodeAt* deferred =
3171 new DeferredStringCharCodeAt(this, instr); 3172 new DeferredStringCharCodeAt(this, instr);
3172 3173
3173 Label flat_string, ascii_string, done; 3174 Label flat_string, ascii_string, cons_string, two_byte_string, done;
3174 3175
3175 // Fetch the instance type of the receiver into result register. 3176 // Fetch the instance type of the receiver into result register.
3176 __ movq(result, FieldOperand(string, HeapObject::kMapOffset)); 3177 __ movq(result, FieldOperand(string, HeapObject::kMapOffset));
3177 __ movzxbl(result, FieldOperand(result, Map::kInstanceTypeOffset)); 3178 __ movzxbl(result, FieldOperand(result, Map::kInstanceTypeOffset));
3178 3179
3179 // We need special handling for non-sequential strings. 3180 // We need special handling for non-sequential strings.
3180 STATIC_ASSERT(kSeqStringTag == 0); 3181 STATIC_ASSERT(kSeqStringTag == 0);
3181 __ testb(result, Immediate(kStringRepresentationMask)); 3182 __ testb(result, Immediate(kStringRepresentationMask));
3182 __ j(zero, &flat_string, Label::kNear); 3183 __ j(zero, &flat_string, Label::kNear);
3183 3184
3184 // Handle cons strings and go to deferred code for the rest. 3185 // Handle non-flat strings.
3185 __ testb(result, Immediate(kIsConsStringMask)); 3186 __ and_(result, Immediate(kStringRepresentationMask));
3186 __ j(zero, deferred->entry()); 3187 __ cmpb(result, Immediate(kConsStringTag));
3188 __ j(equal, &cons_string, Label::kNear);
3189 __ cmpb(result, Immediate(kExternalStringTag));
3190 __ j(equal, deferred->entry());
3191
3192 // SlicedString.
3193 // Unpack slice, add offset and retrieve the result char.
3194 __ movq(offset, FieldOperand(string, SlicedString::kOffsetOffset));
3195 __ SmiToInteger32(offset, offset);
3196 __ movq(string, FieldOperand(string, SlicedString::kParentOffset));
3197 __ movq(result, FieldOperand(string, HeapObject::kMapOffset));
3198 __ movzxbl(result, FieldOperand(result, Map::kInstanceTypeOffset));
3199 __ addq(string, offset);
3200 // Check for ASCII or two-byte string.
3201 STATIC_ASSERT(kAsciiStringTag != 0);
3202 __ testb(result, Immediate(kStringEncodingMask));
3203 __ j(not_zero, &ascii_string, Label::kNear);
3204 __ addq(string, offset);
3205 __ jmp(&two_byte_string, Label::kNear);
3187 3206
3188 // ConsString. 3207 // ConsString.
3189 // Check whether the right hand side is the empty string (i.e. if 3208 // Check whether the right hand side is the empty string (i.e. if
3190 // this is really a flat string in a cons string). If that is not 3209 // this is really a flat string in a cons string). If that is not
3191 // the case we would rather go to the runtime system now to flatten 3210 // the case we would rather go to the runtime system now to flatten
3192 // the string. 3211 // the string.
3212 __ bind(&cons_string);
3193 __ CompareRoot(FieldOperand(string, ConsString::kSecondOffset), 3213 __ CompareRoot(FieldOperand(string, ConsString::kSecondOffset),
3194 Heap::kEmptyStringRootIndex); 3214 Heap::kEmptyStringRootIndex);
3195 __ j(not_equal, deferred->entry()); 3215 __ j(not_equal, deferred->entry());
3196 // Get the first of the two strings and load its instance type. 3216 // Get the first of the two strings and load its instance type.
3197 __ movq(string, FieldOperand(string, ConsString::kFirstOffset)); 3217 __ movq(string, FieldOperand(string, ConsString::kFirstOffset));
3198 __ movq(result, FieldOperand(string, HeapObject::kMapOffset)); 3218 __ movq(result, FieldOperand(string, HeapObject::kMapOffset));
3199 __ movzxbl(result, FieldOperand(result, Map::kInstanceTypeOffset)); 3219 __ movzxbl(result, FieldOperand(result, Map::kInstanceTypeOffset));
3200 // If the first cons component is also non-flat, then go to runtime. 3220 // If the first cons component is also non-flat, then go to runtime.
3201 STATIC_ASSERT(kSeqStringTag == 0); 3221 STATIC_ASSERT(kSeqStringTag == 0);
3202 __ testb(result, Immediate(kStringRepresentationMask)); 3222 __ testb(result, Immediate(kStringRepresentationMask));
3203 __ j(not_zero, deferred->entry()); 3223 __ j(not_zero, deferred->entry());
3204 3224
3205 // Check for ASCII or two-byte string. 3225 // Check for ASCII or two-byte string.
3206 __ bind(&flat_string); 3226 __ bind(&flat_string);
3207 STATIC_ASSERT(kAsciiStringTag != 0); 3227 STATIC_ASSERT(kAsciiStringTag != 0);
3208 __ testb(result, Immediate(kStringEncodingMask)); 3228 __ testb(result, Immediate(kStringEncodingMask));
3209 __ j(not_zero, &ascii_string, Label::kNear); 3229 __ j(not_zero, &ascii_string, Label::kNear);
3210 3230
3211 // Two-byte string. 3231 // Two-byte string.
3212 // Load the two-byte character code into the result register. 3232 // Load the two-byte character code into the result register.
3233 __ bind(&two_byte_string);
3213 STATIC_ASSERT(kSmiTag == 0 && kSmiTagSize == 1); 3234 STATIC_ASSERT(kSmiTag == 0 && kSmiTagSize == 1);
3214 if (instr->index()->IsConstantOperand()) { 3235 if (instr->index()->IsConstantOperand()) {
3215 __ movzxwl(result, 3236 __ movzxwl(result,
3216 FieldOperand(string, 3237 FieldOperand(string,
3217 SeqTwoByteString::kHeaderSize + 3238 SeqTwoByteString::kHeaderSize +
3218 (kUC16Size * const_index))); 3239 (kUC16Size * const_index)));
3219 } else { 3240 } else {
3220 __ movzxwl(result, FieldOperand(string, 3241 __ movzxwl(result, FieldOperand(string,
3221 index, 3242 index,
3222 times_2, 3243 times_2,
(...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after
4104 RegisterEnvironmentForDeoptimization(environment); 4125 RegisterEnvironmentForDeoptimization(environment);
4105 ASSERT(osr_pc_offset_ == -1); 4126 ASSERT(osr_pc_offset_ == -1);
4106 osr_pc_offset_ = masm()->pc_offset(); 4127 osr_pc_offset_ = masm()->pc_offset();
4107 } 4128 }
4108 4129
4109 #undef __ 4130 #undef __
4110 4131
4111 } } // namespace v8::internal 4132 } } // namespace v8::internal
4112 4133
4113 #endif // V8_TARGET_ARCH_X64 4134 #endif // V8_TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698