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

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

Issue 8513010: Add pointer cache field to external string for access in generated code. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: . Created 9 years, 1 month 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 3353 matching lines...) Expand 10 before | Expand all | Expand 10 after
3364 class DeferredStringCharCodeAt: public LDeferredCode { 3364 class DeferredStringCharCodeAt: public LDeferredCode {
3365 public: 3365 public:
3366 DeferredStringCharCodeAt(LCodeGen* codegen, LStringCharCodeAt* instr) 3366 DeferredStringCharCodeAt(LCodeGen* codegen, LStringCharCodeAt* instr)
3367 : LDeferredCode(codegen), instr_(instr) { } 3367 : LDeferredCode(codegen), instr_(instr) { }
3368 virtual void Generate() { codegen()->DoDeferredStringCharCodeAt(instr_); } 3368 virtual void Generate() { codegen()->DoDeferredStringCharCodeAt(instr_); }
3369 virtual LInstruction* instr() { return instr_; } 3369 virtual LInstruction* instr() { return instr_; }
3370 private: 3370 private:
3371 LStringCharCodeAt* instr_; 3371 LStringCharCodeAt* instr_;
3372 }; 3372 };
3373 3373
3374 Register string = ToRegister(instr->string());
3375 Register index = ToRegister(instr->index());
3376 Register result = ToRegister(instr->result());
3377
3378 DeferredStringCharCodeAt* deferred = 3374 DeferredStringCharCodeAt* deferred =
3379 new DeferredStringCharCodeAt(this, instr); 3375 new DeferredStringCharCodeAt(this, instr);
3380 3376
3381 // Fetch the instance type of the receiver into result register. 3377 StringCharCodeAtGenerator::GenerateCharLoad(masm(),
Lasse Reichstein 2011/11/17 13:40:18 If GenerateCharLoad is used from outside StringCha
Yang 2011/11/17 17:06:23 Moved to codegen-*.cc instead. Big chunks of code
3382 __ mov(result, FieldOperand(string, HeapObject::kMapOffset)); 3378 factory(),
3383 __ movzx_b(result, FieldOperand(result, Map::kInstanceTypeOffset)); 3379 ToRegister(instr->string()),
3384 3380 ToRegister(instr->index()),
3385 // We need special handling for indirect strings. 3381 ToRegister(instr->result()),
3386 Label check_sequential; 3382 deferred->entry());
3387 __ test(result, Immediate(kIsIndirectStringMask));
3388 __ j(zero, &check_sequential, Label::kNear);
3389
3390 // Dispatch on the indirect string shape: slice or cons.
3391 Label cons_string;
3392 __ test(result, Immediate(kSlicedNotConsMask));
3393 __ j(zero, &cons_string, Label::kNear);
3394
3395 // Handle slices.
3396 Label indirect_string_loaded;
3397 __ mov(result, FieldOperand(string, SlicedString::kOffsetOffset));
3398 __ SmiUntag(result);
3399 __ add(index, Operand(result));
3400 __ mov(string, FieldOperand(string, SlicedString::kParentOffset));
3401 __ jmp(&indirect_string_loaded, Label::kNear);
3402
3403 // Handle conses.
3404 // Check whether the right hand side is the empty string (i.e. if
3405 // this is really a flat string in a cons string). If that is not
3406 // the case we would rather go to the runtime system now to flatten
3407 // the string.
3408 __ bind(&cons_string);
3409 __ cmp(FieldOperand(string, ConsString::kSecondOffset),
3410 Immediate(factory()->empty_string()));
3411 __ j(not_equal, deferred->entry());
3412 __ mov(string, FieldOperand(string, ConsString::kFirstOffset));
3413
3414 __ bind(&indirect_string_loaded);
3415 __ mov(result, FieldOperand(string, HeapObject::kMapOffset));
3416 __ movzx_b(result, FieldOperand(result, Map::kInstanceTypeOffset));
3417
3418 // Check whether the string is sequential. The only non-sequential
3419 // shapes we support have just been unwrapped above.
3420 // Note that if the original string is a cons or slice with an external
3421 // string as underlying string, we pass that unpacked underlying string with
3422 // the adjusted index to the runtime function.
3423 __ bind(&check_sequential);
3424 STATIC_ASSERT(kSeqStringTag == 0);
3425 __ test(result, Immediate(kStringRepresentationMask));
3426 __ j(not_zero, deferred->entry());
3427
3428 // Dispatch on the encoding: ASCII or two-byte.
3429 Label ascii_string;
3430 STATIC_ASSERT((kStringEncodingMask & kAsciiStringTag) != 0);
3431 STATIC_ASSERT((kStringEncodingMask & kTwoByteStringTag) == 0);
3432 __ test(result, Immediate(kStringEncodingMask));
3433 __ j(not_zero, &ascii_string, Label::kNear);
3434
3435 // Two-byte string.
3436 // Load the two-byte character code into the result register.
3437 Label done;
3438 STATIC_ASSERT(kSmiTag == 0 && kSmiTagSize == 1);
3439 __ movzx_w(result, FieldOperand(string,
3440 index,
3441 times_2,
3442 SeqTwoByteString::kHeaderSize));
3443 __ jmp(&done, Label::kNear);
3444
3445 // ASCII string.
3446 // Load the byte into the result register.
3447 __ bind(&ascii_string);
3448 __ movzx_b(result, FieldOperand(string,
3449 index,
3450 times_1,
3451 SeqAsciiString::kHeaderSize));
3452 __ bind(&done);
3453 __ bind(deferred->exit()); 3383 __ bind(deferred->exit());
3454 } 3384 }
3455 3385
3456 3386
3457 void LCodeGen::DoDeferredStringCharCodeAt(LStringCharCodeAt* instr) { 3387 void LCodeGen::DoDeferredStringCharCodeAt(LStringCharCodeAt* instr) {
3458 Register string = ToRegister(instr->string()); 3388 Register string = ToRegister(instr->string());
3459 Register result = ToRegister(instr->result()); 3389 Register result = ToRegister(instr->result());
3460 3390
3461 // TODO(3095996): Get rid of this. For now, we need to make the 3391 // TODO(3095996): Get rid of this. For now, we need to make the
3462 // result register contain a valid pointer because it is already 3392 // result register contain a valid pointer because it is already
(...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after
4570 this, pointers, Safepoint::kLazyDeopt); 4500 this, pointers, Safepoint::kLazyDeopt);
4571 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); 4501 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator);
4572 } 4502 }
4573 4503
4574 4504
4575 #undef __ 4505 #undef __
4576 4506
4577 } } // namespace v8::internal 4507 } } // namespace v8::internal
4578 4508
4579 #endif // V8_TARGET_ARCH_IA32 4509 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698