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

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

Issue 8662009: Porting r10023 and r10054 to x64 (pointer cache for external strings). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years 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
« src/x64/codegen-x64.cc ('K') | « src/x64/codegen-x64.cc ('k') | 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 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 3288 matching lines...) Expand 10 before | Expand all | Expand 10 after
3299 class DeferredStringCharCodeAt: public LDeferredCode { 3299 class DeferredStringCharCodeAt: public LDeferredCode {
3300 public: 3300 public:
3301 DeferredStringCharCodeAt(LCodeGen* codegen, LStringCharCodeAt* instr) 3301 DeferredStringCharCodeAt(LCodeGen* codegen, LStringCharCodeAt* instr)
3302 : LDeferredCode(codegen), instr_(instr) { } 3302 : LDeferredCode(codegen), instr_(instr) { }
3303 virtual void Generate() { codegen()->DoDeferredStringCharCodeAt(instr_); } 3303 virtual void Generate() { codegen()->DoDeferredStringCharCodeAt(instr_); }
3304 virtual LInstruction* instr() { return instr_; } 3304 virtual LInstruction* instr() { return instr_; }
3305 private: 3305 private:
3306 LStringCharCodeAt* instr_; 3306 LStringCharCodeAt* instr_;
3307 }; 3307 };
3308 3308
3309 Register string = ToRegister(instr->string());
3310 Register index = ToRegister(instr->index());
3311 Register result = ToRegister(instr->result());
3312
3313 DeferredStringCharCodeAt* deferred = 3309 DeferredStringCharCodeAt* deferred =
3314 new DeferredStringCharCodeAt(this, instr); 3310 new DeferredStringCharCodeAt(this, instr);
3315 3311
3316 // Fetch the instance type of the receiver into result register. 3312 StringCharLoadGenerator::Generate(masm(),
3317 __ movq(result, FieldOperand(string, HeapObject::kMapOffset)); 3313 ToRegister(instr->string()),
3318 __ movzxbl(result, FieldOperand(result, Map::kInstanceTypeOffset)); 3314 ToRegister(instr->index()),
3319 3315 ToRegister(instr->result()),
3320 // We need special handling for indirect strings. 3316 deferred->entry());
3321 Label check_sequential;
3322 __ testb(result, Immediate(kIsIndirectStringMask));
3323 __ j(zero, &check_sequential, Label::kNear);
3324
3325 // Dispatch on the indirect string shape: slice or cons.
3326 Label cons_string;
3327 __ testb(result, Immediate(kSlicedNotConsMask));
3328 __ j(zero, &cons_string, Label::kNear);
3329
3330 // Handle slices.
3331 Label indirect_string_loaded;
3332 __ SmiToInteger32(result, FieldOperand(string, SlicedString::kOffsetOffset));
3333 __ addq(index, result);
3334 __ movq(string, FieldOperand(string, SlicedString::kParentOffset));
3335 __ jmp(&indirect_string_loaded, Label::kNear);
3336
3337 // Handle conses.
3338 // Check whether the right hand side is the empty string (i.e. if
3339 // this is really a flat string in a cons string). If that is not
3340 // the case we would rather go to the runtime system now to flatten
3341 // the string.
3342 __ bind(&cons_string);
3343 __ CompareRoot(FieldOperand(string, ConsString::kSecondOffset),
3344 Heap::kEmptyStringRootIndex);
3345 __ j(not_equal, deferred->entry());
3346 __ movq(string, FieldOperand(string, ConsString::kFirstOffset));
3347
3348 __ bind(&indirect_string_loaded);
3349 __ movq(result, FieldOperand(string, HeapObject::kMapOffset));
3350 __ movzxbl(result, FieldOperand(result, Map::kInstanceTypeOffset));
3351
3352 // Check whether the string is sequential. The only non-sequential
3353 // shapes we support have just been unwrapped above.
3354 // Note that if the original string is a cons or slice with an external
3355 // string as underlying string, we pass that unpacked underlying string with
3356 // the adjusted index to the runtime function.
3357 __ bind(&check_sequential);
3358 STATIC_ASSERT(kSeqStringTag == 0);
3359 __ testb(result, Immediate(kStringRepresentationMask));
3360 __ j(not_zero, deferred->entry());
3361
3362 // Dispatch on the encoding: ASCII or two-byte.
3363 Label ascii_string;
3364 STATIC_ASSERT((kStringEncodingMask & kAsciiStringTag) != 0);
3365 STATIC_ASSERT((kStringEncodingMask & kTwoByteStringTag) == 0);
3366 __ testb(result, Immediate(kStringEncodingMask));
3367 __ j(not_zero, &ascii_string, Label::kNear);
3368
3369 // Two-byte string.
3370 // Load the two-byte character code into the result register.
3371 Label done;
3372 STATIC_ASSERT(kSmiTag == 0 && kSmiTagSize == 1);
3373 __ movzxwl(result, FieldOperand(string,
3374 index,
3375 times_2,
3376 SeqTwoByteString::kHeaderSize));
3377 __ jmp(&done, Label::kNear);
3378
3379 // ASCII string.
3380 // Load the byte into the result register.
3381 __ bind(&ascii_string);
3382 __ movzxbl(result, FieldOperand(string,
3383 index,
3384 times_1,
3385 SeqAsciiString::kHeaderSize));
3386 __ bind(&done);
3387 __ bind(deferred->exit()); 3317 __ bind(deferred->exit());
3388 } 3318 }
3389 3319
3390 3320
3391 void LCodeGen::DoDeferredStringCharCodeAt(LStringCharCodeAt* instr) { 3321 void LCodeGen::DoDeferredStringCharCodeAt(LStringCharCodeAt* instr) {
3392 Register string = ToRegister(instr->string()); 3322 Register string = ToRegister(instr->string());
3393 Register result = ToRegister(instr->result()); 3323 Register result = ToRegister(instr->result());
3394 3324
3395 // TODO(3095996): Get rid of this. For now, we need to make the 3325 // TODO(3095996): Get rid of this. For now, we need to make the
3396 // result register contain a valid pointer because it is already 3326 // result register contain a valid pointer because it is already
(...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after
4301 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); 4231 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt);
4302 ASSERT(osr_pc_offset_ == -1); 4232 ASSERT(osr_pc_offset_ == -1);
4303 osr_pc_offset_ = masm()->pc_offset(); 4233 osr_pc_offset_ = masm()->pc_offset();
4304 } 4234 }
4305 4235
4306 #undef __ 4236 #undef __
4307 4237
4308 } } // namespace v8::internal 4238 } } // namespace v8::internal
4309 4239
4310 #endif // V8_TARGET_ARCH_X64 4240 #endif // V8_TARGET_ARCH_X64
OLDNEW
« src/x64/codegen-x64.cc ('K') | « src/x64/codegen-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698