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

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

Issue 6711027: [Isolates] Merge 7201:7258 from bleeding_edge to isolates. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: Created 9 years, 9 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 846 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 857
858 858
859 void LCodeGen::DoMulI(LMulI* instr) { 859 void LCodeGen::DoMulI(LMulI* instr) {
860 Register left = ToRegister(instr->InputAt(0)); 860 Register left = ToRegister(instr->InputAt(0));
861 LOperand* right = instr->InputAt(1); 861 LOperand* right = instr->InputAt(1);
862 862
863 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { 863 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
864 __ movl(kScratchRegister, left); 864 __ movl(kScratchRegister, left);
865 } 865 }
866 866
867 bool can_overflow =
868 instr->hydrogen()->CheckFlag(HValue::kCanOverflow);
867 if (right->IsConstantOperand()) { 869 if (right->IsConstantOperand()) {
868 int right_value = ToInteger32(LConstantOperand::cast(right)); 870 int right_value = ToInteger32(LConstantOperand::cast(right));
869 __ imull(left, left, Immediate(right_value)); 871 if (right_value == -1) {
872 __ negl(left);
873 } else if (right_value == 0) {
874 __ xorl(left, left);
875 } else if (right_value == 2) {
876 __ addl(left, left);
877 } else if (!can_overflow) {
878 // If the multiplication is known to not overflow, we
879 // can use operations that don't set the overflow flag
880 // correctly.
881 switch (right_value) {
882 case 1:
883 // Do nothing.
884 break;
885 case 3:
886 __ leal(left, Operand(left, left, times_2, 0));
887 break;
888 case 4:
889 __ shll(left, Immediate(2));
890 break;
891 case 5:
892 __ leal(left, Operand(left, left, times_4, 0));
893 break;
894 case 8:
895 __ shll(left, Immediate(3));
896 break;
897 case 9:
898 __ leal(left, Operand(left, left, times_8, 0));
899 break;
900 case 16:
901 __ shll(left, Immediate(4));
902 break;
903 default:
904 __ imull(left, left, Immediate(right_value));
905 break;
906 }
907 } else {
908 __ imull(left, left, Immediate(right_value));
909 }
870 } else if (right->IsStackSlot()) { 910 } else if (right->IsStackSlot()) {
871 __ imull(left, ToOperand(right)); 911 __ imull(left, ToOperand(right));
872 } else { 912 } else {
873 __ imull(left, ToRegister(right)); 913 __ imull(left, ToRegister(right));
874 } 914 }
875 915
876 if (instr->hydrogen()->CheckFlag(HValue::kCanOverflow)) { 916 if (can_overflow) {
877 DeoptimizeIf(overflow, instr->environment()); 917 DeoptimizeIf(overflow, instr->environment());
878 } 918 }
879 919
880 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { 920 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
881 // Bail out if the result is supposed to be negative zero. 921 // Bail out if the result is supposed to be negative zero.
882 NearLabel done; 922 NearLabel done;
883 __ testl(left, left); 923 __ testl(left, left);
884 __ j(not_zero, &done); 924 __ j(not_zero, &done);
885 if (right->IsConstantOperand()) { 925 if (right->IsConstantOperand()) {
886 if (ToInteger32(LConstantOperand::cast(right)) <= 0) { 926 if (ToInteger32(LConstantOperand::cast(right)) <= 0) {
(...skipping 1449 matching lines...) Expand 10 before | Expand all | Expand 10 after
2336 } 2376 }
2337 2377
2338 2378
2339 void LCodeGen::DoGlobalObject(LGlobalObject* instr) { 2379 void LCodeGen::DoGlobalObject(LGlobalObject* instr) {
2340 Register result = ToRegister(instr->result()); 2380 Register result = ToRegister(instr->result());
2341 __ movq(result, GlobalObjectOperand()); 2381 __ movq(result, GlobalObjectOperand());
2342 } 2382 }
2343 2383
2344 2384
2345 void LCodeGen::DoGlobalReceiver(LGlobalReceiver* instr) { 2385 void LCodeGen::DoGlobalReceiver(LGlobalReceiver* instr) {
2386 Register global = ToRegister(instr->global());
2346 Register result = ToRegister(instr->result()); 2387 Register result = ToRegister(instr->result());
2347 __ movq(result, Operand(rsi, Context::SlotOffset(Context::GLOBAL_INDEX))); 2388 __ movq(result, FieldOperand(global, GlobalObject::kGlobalReceiverOffset));
2348 __ movq(result, FieldOperand(result, GlobalObject::kGlobalReceiverOffset));
2349 } 2389 }
2350 2390
2351 2391
2352 void LCodeGen::CallKnownFunction(Handle<JSFunction> function, 2392 void LCodeGen::CallKnownFunction(Handle<JSFunction> function,
2353 int arity, 2393 int arity,
2354 LInstruction* instr) { 2394 LInstruction* instr) {
2355 // Change context if needed. 2395 // Change context if needed.
2356 bool change_context = 2396 bool change_context =
2357 (info()->closure()->context() != function->context()) || 2397 (info()->closure()->context() != function->context()) ||
2358 scope()->contains_with() || 2398 scope()->contains_with() ||
(...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after
3295 __ andl(result_reg, Immediate(1)); 3335 __ andl(result_reg, Immediate(1));
3296 DeoptimizeIf(not_zero, instr->environment()); 3336 DeoptimizeIf(not_zero, instr->environment());
3297 __ bind(&done); 3337 __ bind(&done);
3298 } 3338 }
3299 } 3339 }
3300 } 3340 }
3301 3341
3302 3342
3303 void LCodeGen::DoCheckSmi(LCheckSmi* instr) { 3343 void LCodeGen::DoCheckSmi(LCheckSmi* instr) {
3304 LOperand* input = instr->InputAt(0); 3344 LOperand* input = instr->InputAt(0);
3305 ASSERT(input->IsRegister());
3306 Condition cc = masm()->CheckSmi(ToRegister(input)); 3345 Condition cc = masm()->CheckSmi(ToRegister(input));
3307 if (instr->condition() != equal) { 3346 DeoptimizeIf(NegateCondition(cc), instr->environment());
3308 cc = NegateCondition(cc); 3347 }
3309 } 3348
3349
3350 void LCodeGen::DoCheckNonSmi(LCheckNonSmi* instr) {
3351 LOperand* input = instr->InputAt(0);
3352 Condition cc = masm()->CheckSmi(ToRegister(input));
3310 DeoptimizeIf(cc, instr->environment()); 3353 DeoptimizeIf(cc, instr->environment());
3311 } 3354 }
3312 3355
3313 3356
3314 void LCodeGen::DoCheckInstanceType(LCheckInstanceType* instr) { 3357 void LCodeGen::DoCheckInstanceType(LCheckInstanceType* instr) {
3315 Register input = ToRegister(instr->InputAt(0)); 3358 Register input = ToRegister(instr->InputAt(0));
3316 InstanceType first = instr->hydrogen()->first(); 3359 InstanceType first = instr->hydrogen()->first();
3317 InstanceType last = instr->hydrogen()->last(); 3360 InstanceType last = instr->hydrogen()->last();
3318 3361
3319 __ movq(kScratchRegister, FieldOperand(input, HeapObject::kMapOffset)); 3362 __ movq(kScratchRegister, FieldOperand(input, HeapObject::kMapOffset));
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
3494 __ movq(FieldOperand(rax, size - kPointerSize), rdx); 3537 __ movq(FieldOperand(rax, size - kPointerSize), rdx);
3495 } 3538 }
3496 } 3539 }
3497 3540
3498 3541
3499 void LCodeGen::DoFunctionLiteral(LFunctionLiteral* instr) { 3542 void LCodeGen::DoFunctionLiteral(LFunctionLiteral* instr) {
3500 // Use the fast case closure allocation code that allocates in new 3543 // Use the fast case closure allocation code that allocates in new
3501 // space for nested functions that don't need literals cloning. 3544 // space for nested functions that don't need literals cloning.
3502 Handle<SharedFunctionInfo> shared_info = instr->shared_info(); 3545 Handle<SharedFunctionInfo> shared_info = instr->shared_info();
3503 bool pretenure = instr->hydrogen()->pretenure(); 3546 bool pretenure = instr->hydrogen()->pretenure();
3504 if (shared_info->num_literals() == 0 && !pretenure) { 3547 if (!pretenure && shared_info->num_literals() == 0) {
3505 FastNewClosureStub stub; 3548 FastNewClosureStub stub(
3549 shared_info->strict_mode() ? kStrictMode : kNonStrictMode);
3506 __ Push(shared_info); 3550 __ Push(shared_info);
3507 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); 3551 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
3508 } else { 3552 } else {
3509 __ push(rsi); 3553 __ push(rsi);
3510 __ Push(shared_info); 3554 __ Push(shared_info);
3511 __ PushRoot(pretenure ? 3555 __ PushRoot(pretenure ?
3512 Heap::kTrueValueRootIndex : 3556 Heap::kTrueValueRootIndex :
3513 Heap::kFalseValueRootIndex); 3557 Heap::kFalseValueRootIndex);
3514 CallRuntime(Runtime::kNewClosure, 3, instr); 3558 CallRuntime(Runtime::kNewClosure, 3, instr);
3515 } 3559 }
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
3768 RegisterEnvironmentForDeoptimization(environment); 3812 RegisterEnvironmentForDeoptimization(environment);
3769 ASSERT(osr_pc_offset_ == -1); 3813 ASSERT(osr_pc_offset_ == -1);
3770 osr_pc_offset_ = masm()->pc_offset(); 3814 osr_pc_offset_ = masm()->pc_offset();
3771 } 3815 }
3772 3816
3773 #undef __ 3817 #undef __
3774 3818
3775 } } // namespace v8::internal 3819 } } // namespace v8::internal
3776 3820
3777 #endif // V8_TARGET_ARCH_X64 3821 #endif // V8_TARGET_ARCH_X64
OLDNEW
« src/global-handles.cc ('K') | « src/x64/full-codegen-x64.cc ('k') | src/x64/lithium-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698