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

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

Issue 7860035: Merge bleeding edge up to 9192 into the GC branch. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/gc
Patch Set: Created 9 years, 3 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 | « src/x64/ic-x64.cc ('k') | src/x64/lithium-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 __ CallRuntime(Runtime::kNewFunctionContext, 1); 200 __ CallRuntime(Runtime::kNewFunctionContext, 1);
201 } 201 }
202 RecordSafepoint(Safepoint::kNoDeoptimizationIndex); 202 RecordSafepoint(Safepoint::kNoDeoptimizationIndex);
203 // Context is returned in both rax and rsi. It replaces the context 203 // Context is returned in both rax and rsi. It replaces the context
204 // passed to us. It's saved in the stack and kept live in rsi. 204 // passed to us. It's saved in the stack and kept live in rsi.
205 __ movq(Operand(rbp, StandardFrameConstants::kContextOffset), rsi); 205 __ movq(Operand(rbp, StandardFrameConstants::kContextOffset), rsi);
206 206
207 // Copy any necessary parameters into the context. 207 // Copy any necessary parameters into the context.
208 int num_parameters = scope()->num_parameters(); 208 int num_parameters = scope()->num_parameters();
209 for (int i = 0; i < num_parameters; i++) { 209 for (int i = 0; i < num_parameters; i++) {
210 Slot* slot = scope()->parameter(i)->AsSlot(); 210 Variable* var = scope()->parameter(i);
211 if (slot != NULL && slot->type() == Slot::CONTEXT) { 211 if (var->IsContextSlot()) {
212 int parameter_offset = StandardFrameConstants::kCallerSPOffset + 212 int parameter_offset = StandardFrameConstants::kCallerSPOffset +
213 (num_parameters - 1 - i) * kPointerSize; 213 (num_parameters - 1 - i) * kPointerSize;
214 // Load parameter from stack. 214 // Load parameter from stack.
215 __ movq(rax, Operand(rbp, parameter_offset)); 215 __ movq(rax, Operand(rbp, parameter_offset));
216 // Store it in the context. 216 // Store it in the context.
217 int context_offset = Context::SlotOffset(slot->index()); 217 int context_offset = Context::SlotOffset(var->index());
218 __ movq(Operand(rsi, context_offset), rax); 218 __ movq(Operand(rsi, context_offset), rax);
219 // Update the write barrier. This clobbers rax and rbx. 219 // Update the write barrier. This clobbers rax and rbx.
220 __ RecordWriteContextSlot(rsi, context_offset, rax, rbx, kSaveFPRegs); 220 __ RecordWriteContextSlot(rsi, context_offset, rax, rbx, kSaveFPRegs);
221 } 221 }
222 } 222 }
223 Comment(";;; End allocate local context"); 223 Comment(";;; End allocate local context");
224 } 224 }
225 225
226 // Trace the call. 226 // Trace the call.
227 if (FLAG_trace) { 227 if (FLAG_trace) {
(...skipping 2976 matching lines...) Expand 10 before | Expand all | Expand 10 after
3204 class DeferredStringCharCodeAt: public LDeferredCode { 3204 class DeferredStringCharCodeAt: public LDeferredCode {
3205 public: 3205 public:
3206 DeferredStringCharCodeAt(LCodeGen* codegen, LStringCharCodeAt* instr) 3206 DeferredStringCharCodeAt(LCodeGen* codegen, LStringCharCodeAt* instr)
3207 : LDeferredCode(codegen), instr_(instr) { } 3207 : LDeferredCode(codegen), instr_(instr) { }
3208 virtual void Generate() { codegen()->DoDeferredStringCharCodeAt(instr_); } 3208 virtual void Generate() { codegen()->DoDeferredStringCharCodeAt(instr_); }
3209 private: 3209 private:
3210 LStringCharCodeAt* instr_; 3210 LStringCharCodeAt* instr_;
3211 }; 3211 };
3212 3212
3213 Register string = ToRegister(instr->string()); 3213 Register string = ToRegister(instr->string());
3214 Register index = no_reg; 3214 Register index = ToRegister(instr->index());
3215 int const_index = -1;
3216 if (instr->index()->IsConstantOperand()) {
3217 const_index = ToInteger32(LConstantOperand::cast(instr->index()));
3218 STATIC_ASSERT(String::kMaxLength <= Smi::kMaxValue);
3219 if (!Smi::IsValid(const_index)) {
3220 // Guaranteed to be out of bounds because of the assert above.
3221 // So the bounds check that must dominate this instruction must
3222 // have deoptimized already.
3223 if (FLAG_debug_code) {
3224 __ Abort("StringCharCodeAt: out of bounds index.");
3225 }
3226 // No code needs to be generated.
3227 return;
3228 }
3229 } else {
3230 index = ToRegister(instr->index());
3231 }
3232 Register result = ToRegister(instr->result()); 3215 Register result = ToRegister(instr->result());
3233 3216
3234 DeferredStringCharCodeAt* deferred = 3217 DeferredStringCharCodeAt* deferred =
3235 new DeferredStringCharCodeAt(this, instr); 3218 new DeferredStringCharCodeAt(this, instr);
3236 3219
3237 Label flat_string, ascii_string, done;
3238
3239 // Fetch the instance type of the receiver into result register. 3220 // Fetch the instance type of the receiver into result register.
3240 __ movq(result, FieldOperand(string, HeapObject::kMapOffset)); 3221 __ movq(result, FieldOperand(string, HeapObject::kMapOffset));
3241 __ movzxbl(result, FieldOperand(result, Map::kInstanceTypeOffset)); 3222 __ movzxbl(result, FieldOperand(result, Map::kInstanceTypeOffset));
3242 3223
3243 // We need special handling for non-sequential strings. 3224 // We need special handling for indirect strings.
3244 STATIC_ASSERT(kSeqStringTag == 0); 3225 Label check_sequential;
3245 __ testb(result, Immediate(kStringRepresentationMask)); 3226 __ testb(result, Immediate(kIsIndirectStringMask));
3246 __ j(zero, &flat_string, Label::kNear); 3227 __ j(zero, &check_sequential, Label::kNear);
3247 3228
3248 // Handle cons strings and go to deferred code for the rest. 3229 // Dispatch on the indirect string shape: slice or cons.
3249 __ testb(result, Immediate(kIsConsStringMask)); 3230 Label cons_string;
3250 __ j(zero, deferred->entry()); 3231 __ testb(result, Immediate(kSlicedNotConsMask));
3232 __ j(zero, &cons_string, Label::kNear);
3251 3233
3252 // ConsString. 3234 // Handle slices.
3235 Label indirect_string_loaded;
3236 __ SmiToInteger32(result, FieldOperand(string, SlicedString::kOffsetOffset));
3237 __ addq(index, result);
3238 __ movq(string, FieldOperand(string, SlicedString::kParentOffset));
3239 __ jmp(&indirect_string_loaded, Label::kNear);
3240
3241 // Handle conses.
3253 // Check whether the right hand side is the empty string (i.e. if 3242 // Check whether the right hand side is the empty string (i.e. if
3254 // this is really a flat string in a cons string). If that is not 3243 // this is really a flat string in a cons string). If that is not
3255 // the case we would rather go to the runtime system now to flatten 3244 // the case we would rather go to the runtime system now to flatten
3256 // the string. 3245 // the string.
3246 __ bind(&cons_string);
3257 __ CompareRoot(FieldOperand(string, ConsString::kSecondOffset), 3247 __ CompareRoot(FieldOperand(string, ConsString::kSecondOffset),
3258 Heap::kEmptyStringRootIndex); 3248 Heap::kEmptyStringRootIndex);
3259 __ j(not_equal, deferred->entry()); 3249 __ j(not_equal, deferred->entry());
3260 // Get the first of the two strings and load its instance type.
3261 __ movq(string, FieldOperand(string, ConsString::kFirstOffset)); 3250 __ movq(string, FieldOperand(string, ConsString::kFirstOffset));
3251
3252 __ bind(&indirect_string_loaded);
3262 __ movq(result, FieldOperand(string, HeapObject::kMapOffset)); 3253 __ movq(result, FieldOperand(string, HeapObject::kMapOffset));
3263 __ movzxbl(result, FieldOperand(result, Map::kInstanceTypeOffset)); 3254 __ movzxbl(result, FieldOperand(result, Map::kInstanceTypeOffset));
3264 // If the first cons component is also non-flat, then go to runtime. 3255
3256 // Check whether the string is sequential. The only non-sequential
3257 // shapes we support have just been unwrapped above.
3258 __ bind(&check_sequential);
3265 STATIC_ASSERT(kSeqStringTag == 0); 3259 STATIC_ASSERT(kSeqStringTag == 0);
3266 __ testb(result, Immediate(kStringRepresentationMask)); 3260 __ testb(result, Immediate(kStringRepresentationMask));
3267 __ j(not_zero, deferred->entry()); 3261 __ j(not_zero, deferred->entry());
3268 3262
3269 // Check for ASCII or two-byte string. 3263 // Dispatch on the encoding: ASCII or two-byte.
3270 __ bind(&flat_string); 3264 Label ascii_string;
3271 STATIC_ASSERT(kAsciiStringTag != 0); 3265 STATIC_ASSERT((kStringEncodingMask & kAsciiStringTag) != 0);
3266 STATIC_ASSERT((kStringEncodingMask & kTwoByteStringTag) == 0);
3272 __ testb(result, Immediate(kStringEncodingMask)); 3267 __ testb(result, Immediate(kStringEncodingMask));
3273 __ j(not_zero, &ascii_string, Label::kNear); 3268 __ j(not_zero, &ascii_string, Label::kNear);
3274 3269
3275 // Two-byte string. 3270 // Two-byte string.
3276 // Load the two-byte character code into the result register. 3271 // Load the two-byte character code into the result register.
3272 Label done;
3277 STATIC_ASSERT(kSmiTag == 0 && kSmiTagSize == 1); 3273 STATIC_ASSERT(kSmiTag == 0 && kSmiTagSize == 1);
3278 if (instr->index()->IsConstantOperand()) { 3274 __ movzxwl(result, FieldOperand(string,
3279 __ movzxwl(result, 3275 index,
3280 FieldOperand(string, 3276 times_2,
3281 SeqTwoByteString::kHeaderSize + 3277 SeqTwoByteString::kHeaderSize));
3282 (kUC16Size * const_index)));
3283 } else {
3284 __ movzxwl(result, FieldOperand(string,
3285 index,
3286 times_2,
3287 SeqTwoByteString::kHeaderSize));
3288 }
3289 __ jmp(&done, Label::kNear); 3278 __ jmp(&done, Label::kNear);
3290 3279
3291 // ASCII string. 3280 // ASCII string.
3292 // Load the byte into the result register. 3281 // Load the byte into the result register.
3293 __ bind(&ascii_string); 3282 __ bind(&ascii_string);
3294 if (instr->index()->IsConstantOperand()) { 3283 __ movzxbl(result, FieldOperand(string,
3295 __ movzxbl(result, FieldOperand(string, 3284 index,
3296 SeqAsciiString::kHeaderSize + const_index)); 3285 times_1,
3297 } else { 3286 SeqAsciiString::kHeaderSize));
3298 __ movzxbl(result, FieldOperand(string,
3299 index,
3300 times_1,
3301 SeqAsciiString::kHeaderSize));
3302 }
3303 __ bind(&done); 3287 __ bind(&done);
3304 __ bind(deferred->exit()); 3288 __ bind(deferred->exit());
3305 } 3289 }
3306 3290
3307 3291
3308 void LCodeGen::DoDeferredStringCharCodeAt(LStringCharCodeAt* instr) { 3292 void LCodeGen::DoDeferredStringCharCodeAt(LStringCharCodeAt* instr) {
3309 Register string = ToRegister(instr->string()); 3293 Register string = ToRegister(instr->string());
3310 Register result = ToRegister(instr->result()); 3294 Register result = ToRegister(instr->result());
3311 3295
3312 // TODO(3095996): Get rid of this. For now, we need to make the 3296 // TODO(3095996): Get rid of this. For now, we need to make the
(...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after
4174 RegisterEnvironmentForDeoptimization(environment); 4158 RegisterEnvironmentForDeoptimization(environment);
4175 ASSERT(osr_pc_offset_ == -1); 4159 ASSERT(osr_pc_offset_ == -1);
4176 osr_pc_offset_ = masm()->pc_offset(); 4160 osr_pc_offset_ = masm()->pc_offset();
4177 } 4161 }
4178 4162
4179 #undef __ 4163 #undef __
4180 4164
4181 } } // namespace v8::internal 4165 } } // namespace v8::internal
4182 4166
4183 #endif // V8_TARGET_ARCH_X64 4167 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/ic-x64.cc ('k') | src/x64/lithium-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698