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

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

Issue 157543002: A64: Synchronize with r18581. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 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.h » ('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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 if (info()->IsOptimizing()) { 149 if (info()->IsOptimizing()) {
150 ProfileEntryHookStub::MaybeCallEntryHook(masm_); 150 ProfileEntryHookStub::MaybeCallEntryHook(masm_);
151 151
152 #ifdef DEBUG 152 #ifdef DEBUG
153 if (strlen(FLAG_stop_at) > 0 && 153 if (strlen(FLAG_stop_at) > 0 &&
154 info_->function()->name()->IsUtf8EqualTo(CStrVector(FLAG_stop_at))) { 154 info_->function()->name()->IsUtf8EqualTo(CStrVector(FLAG_stop_at))) {
155 __ int3(); 155 __ int3();
156 } 156 }
157 #endif 157 #endif
158 158
159 // Strict mode functions need to replace the receiver with undefined 159 // Classic mode functions need to replace the receiver with the global proxy
160 // when called as functions (without an explicit receiver 160 // when called as functions (without an explicit receiver object).
161 // object). rcx is zero for method calls and non-zero for function 161 if (info_->this_has_uses() &&
162 // calls. 162 info_->is_classic_mode() &&
163 if (!info_->is_classic_mode() || info_->is_native()) { 163 !info_->is_native()) {
164 Label ok; 164 Label ok;
165 __ testq(rcx, rcx); 165 __ testq(rcx, rcx);
166 __ j(zero, &ok, Label::kNear); 166 __ j(zero, &ok, Label::kNear);
167
167 StackArgumentsAccessor args(rsp, scope()->num_parameters()); 168 StackArgumentsAccessor args(rsp, scope()->num_parameters());
168 __ LoadRoot(kScratchRegister, Heap::kUndefinedValueRootIndex); 169 __ movq(rcx, args.GetReceiverOperand());
169 __ movq(args.GetReceiverOperand(), kScratchRegister); 170
171 __ CompareRoot(rcx, Heap::kUndefinedValueRootIndex);
172 __ j(not_equal, &ok, Label::kNear);
173
174 __ movq(rcx, GlobalObjectOperand());
175 __ movq(rcx, FieldOperand(rcx, GlobalObject::kGlobalReceiverOffset));
176
177 __ movq(args.GetReceiverOperand(), rcx);
178
170 __ bind(&ok); 179 __ bind(&ok);
171 } 180 }
172 } 181 }
173 182
174 info()->set_prologue_offset(masm_->pc_offset()); 183 info()->set_prologue_offset(masm_->pc_offset());
175 if (NeedsEagerFrame()) { 184 if (NeedsEagerFrame()) {
176 ASSERT(!frame_is_built_); 185 ASSERT(!frame_is_built_);
177 frame_is_built_ = true; 186 frame_is_built_ = true;
178 __ Prologue(info()->IsStub() ? BUILD_STUB_FRAME : BUILD_FUNCTION_FRAME); 187 __ Prologue(info()->IsStub() ? BUILD_STUB_FRAME : BUILD_FUNCTION_FRAME);
179 info()->AddNoFrameRange(0, masm_->pc_offset()); 188 info()->AddNoFrameRange(0, masm_->pc_offset());
(...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after
1116 } else { 1125 } else {
1117 Register reg1 = ToRegister(instr->temp()); 1126 Register reg1 = ToRegister(instr->temp());
1118 Register reg2 = ToRegister(instr->result()); 1127 Register reg2 = ToRegister(instr->result());
1119 1128
1120 // Find b which: 2^b < divisor_abs < 2^(b+1). 1129 // Find b which: 2^b < divisor_abs < 2^(b+1).
1121 unsigned b = 31 - CompilerIntrinsics::CountLeadingZeros(divisor_abs); 1130 unsigned b = 31 - CompilerIntrinsics::CountLeadingZeros(divisor_abs);
1122 unsigned shift = 32 + b; // Precision +1bit (effectively). 1131 unsigned shift = 32 + b; // Precision +1bit (effectively).
1123 double multiplier_f = 1132 double multiplier_f =
1124 static_cast<double>(static_cast<uint64_t>(1) << shift) / divisor_abs; 1133 static_cast<double>(static_cast<uint64_t>(1) << shift) / divisor_abs;
1125 int64_t multiplier; 1134 int64_t multiplier;
1126 if (multiplier_f - floor(multiplier_f) < 0.5) { 1135 if (multiplier_f - std::floor(multiplier_f) < 0.5) {
1127 multiplier = static_cast<int64_t>(floor(multiplier_f)); 1136 multiplier = static_cast<int64_t>(std::floor(multiplier_f));
1128 } else { 1137 } else {
1129 multiplier = static_cast<int64_t>(floor(multiplier_f)) + 1; 1138 multiplier = static_cast<int64_t>(std::floor(multiplier_f)) + 1;
1130 } 1139 }
1131 // The multiplier is a uint32. 1140 // The multiplier is a uint32.
1132 ASSERT(multiplier > 0 && 1141 ASSERT(multiplier > 0 &&
1133 multiplier < (static_cast<int64_t>(1) << 32)); 1142 multiplier < (static_cast<int64_t>(1) << 32));
1134 // The multiply is int64, so sign-extend to r64. 1143 // The multiply is int64, so sign-extend to r64.
1135 __ movsxlq(reg1, dividend); 1144 __ movsxlq(reg1, dividend);
1136 if (divisor < 0 && 1145 if (divisor < 0 &&
1137 instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { 1146 instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
1138 __ neg(reg1); 1147 __ neg(reg1);
1139 DeoptimizeIf(zero, instr->environment()); 1148 DeoptimizeIf(zero, instr->environment());
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
1632 __ cmpq(kScratchRegister, FieldOperand(object, 1641 __ cmpq(kScratchRegister, FieldOperand(object,
1633 JSDate::kCacheStampOffset)); 1642 JSDate::kCacheStampOffset));
1634 __ j(not_equal, &runtime, Label::kNear); 1643 __ j(not_equal, &runtime, Label::kNear);
1635 __ movq(result, FieldOperand(object, JSDate::kValueOffset + 1644 __ movq(result, FieldOperand(object, JSDate::kValueOffset +
1636 kPointerSize * index->value())); 1645 kPointerSize * index->value()));
1637 __ jmp(&done, Label::kNear); 1646 __ jmp(&done, Label::kNear);
1638 } 1647 }
1639 __ bind(&runtime); 1648 __ bind(&runtime);
1640 __ PrepareCallCFunction(2); 1649 __ PrepareCallCFunction(2);
1641 __ movq(arg_reg_1, object); 1650 __ movq(arg_reg_1, object);
1642 __ movq(arg_reg_2, index, RelocInfo::NONE64); 1651 __ Move(arg_reg_2, index, RelocInfo::NONE64);
1643 __ CallCFunction(ExternalReference::get_date_field_function(isolate()), 2); 1652 __ CallCFunction(ExternalReference::get_date_field_function(isolate()), 2);
1644 __ bind(&done); 1653 __ bind(&done);
1645 } 1654 }
1646 } 1655 }
1647 1656
1648 1657
1649 Operand LCodeGen::BuildSeqStringOperand(Register string, 1658 Operand LCodeGen::BuildSeqStringOperand(Register string,
1650 LOperand* index, 1659 LOperand* index,
1651 String::Encoding encoding) { 1660 String::Encoding encoding) {
1652 if (index->IsConstantOperand()) { 1661 if (index->IsConstantOperand()) {
(...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after
2553 2562
2554 // This is the inlined call site instanceof cache. The two occurences of the 2563 // This is the inlined call site instanceof cache. The two occurences of the
2555 // hole value will be patched to the last map/result pair generated by the 2564 // hole value will be patched to the last map/result pair generated by the
2556 // instanceof stub. 2565 // instanceof stub.
2557 Label cache_miss; 2566 Label cache_miss;
2558 // Use a temp register to avoid memory operands with variable lengths. 2567 // Use a temp register to avoid memory operands with variable lengths.
2559 Register map = ToRegister(instr->temp()); 2568 Register map = ToRegister(instr->temp());
2560 __ movq(map, FieldOperand(object, HeapObject::kMapOffset)); 2569 __ movq(map, FieldOperand(object, HeapObject::kMapOffset));
2561 __ bind(deferred->map_check()); // Label for calculating code patching. 2570 __ bind(deferred->map_check()); // Label for calculating code patching.
2562 Handle<Cell> cache_cell = factory()->NewCell(factory()->the_hole_value()); 2571 Handle<Cell> cache_cell = factory()->NewCell(factory()->the_hole_value());
2563 __ movq(kScratchRegister, cache_cell, RelocInfo::CELL); 2572 __ Move(kScratchRegister, cache_cell, RelocInfo::CELL);
2564 __ cmpq(map, Operand(kScratchRegister, 0)); 2573 __ cmpq(map, Operand(kScratchRegister, 0));
2565 __ j(not_equal, &cache_miss, Label::kNear); 2574 __ j(not_equal, &cache_miss, Label::kNear);
2566 // Patched to load either true or false. 2575 // Patched to load either true or false.
2567 __ LoadRoot(ToRegister(instr->result()), Heap::kTheHoleValueRootIndex); 2576 __ LoadRoot(ToRegister(instr->result()), Heap::kTheHoleValueRootIndex);
2568 #ifdef DEBUG 2577 #ifdef DEBUG
2569 // Check that the code size between patch label and patch sites is invariant. 2578 // Check that the code size between patch label and patch sites is invariant.
2570 Label end_of_patched_code; 2579 Label end_of_patched_code;
2571 __ bind(&end_of_patched_code); 2580 __ bind(&end_of_patched_code);
2572 ASSERT(true); 2581 ASSERT(true);
2573 #endif 2582 #endif
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
2701 } 2710 }
2702 } 2711 }
2703 2712
2704 2713
2705 void LCodeGen::DoLoadGlobalGeneric(LLoadGlobalGeneric* instr) { 2714 void LCodeGen::DoLoadGlobalGeneric(LLoadGlobalGeneric* instr) {
2706 ASSERT(ToRegister(instr->context()).is(rsi)); 2715 ASSERT(ToRegister(instr->context()).is(rsi));
2707 ASSERT(ToRegister(instr->global_object()).is(rax)); 2716 ASSERT(ToRegister(instr->global_object()).is(rax));
2708 ASSERT(ToRegister(instr->result()).is(rax)); 2717 ASSERT(ToRegister(instr->result()).is(rax));
2709 2718
2710 __ Move(rcx, instr->name()); 2719 __ Move(rcx, instr->name());
2711 RelocInfo::Mode mode = instr->for_typeof() ? RelocInfo::CODE_TARGET : 2720 ContextualMode mode = instr->for_typeof() ? NOT_CONTEXTUAL : CONTEXTUAL;
2712 RelocInfo::CODE_TARGET_CONTEXT; 2721 Handle<Code> ic = LoadIC::initialize_stub(isolate(), mode);
2713 Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize(); 2722 CallCode(ic, RelocInfo::CODE_TARGET, instr);
2714 CallCode(ic, mode, instr);
2715 } 2723 }
2716 2724
2717 2725
2718 void LCodeGen::DoStoreGlobalCell(LStoreGlobalCell* instr) { 2726 void LCodeGen::DoStoreGlobalCell(LStoreGlobalCell* instr) {
2719 Register value = ToRegister(instr->value()); 2727 Register value = ToRegister(instr->value());
2720 Handle<Cell> cell_handle = instr->hydrogen()->cell().handle(); 2728 Handle<Cell> cell_handle = instr->hydrogen()->cell().handle();
2721 2729
2722 // If the cell we are storing to contains the hole it could have 2730 // If the cell we are storing to contains the hole it could have
2723 // been deleted from the property dictionary. In that case, we need 2731 // been deleted from the property dictionary. In that case, we need
2724 // to update the property details in the property dictionary to mark 2732 // to update the property details in the property dictionary to mark
2725 // it as no longer deleted. We deoptimize in that case. 2733 // it as no longer deleted. We deoptimize in that case.
2726 if (instr->hydrogen()->RequiresHoleCheck()) { 2734 if (instr->hydrogen()->RequiresHoleCheck()) {
2727 // We have a temp because CompareRoot might clobber kScratchRegister. 2735 // We have a temp because CompareRoot might clobber kScratchRegister.
2728 Register cell = ToRegister(instr->temp()); 2736 Register cell = ToRegister(instr->temp());
2729 ASSERT(!value.is(cell)); 2737 ASSERT(!value.is(cell));
2730 __ movq(cell, cell_handle, RelocInfo::CELL); 2738 __ Move(cell, cell_handle, RelocInfo::CELL);
2731 __ CompareRoot(Operand(cell, 0), Heap::kTheHoleValueRootIndex); 2739 __ CompareRoot(Operand(cell, 0), Heap::kTheHoleValueRootIndex);
2732 DeoptimizeIf(equal, instr->environment()); 2740 DeoptimizeIf(equal, instr->environment());
2733 // Store the value. 2741 // Store the value.
2734 __ movq(Operand(cell, 0), value); 2742 __ movq(Operand(cell, 0), value);
2735 } else { 2743 } else {
2736 // Store the value. 2744 // Store the value.
2737 __ movq(kScratchRegister, cell_handle, RelocInfo::CELL); 2745 __ Move(kScratchRegister, cell_handle, RelocInfo::CELL);
2738 __ movq(Operand(kScratchRegister, 0), value); 2746 __ movq(Operand(kScratchRegister, 0), value);
2739 } 2747 }
2740 // Cells are always rescanned, so no write barrier here. 2748 // Cells are always rescanned, so no write barrier here.
2741 } 2749 }
2742 2750
2743 2751
2744 void LCodeGen::DoStoreGlobalGeneric(LStoreGlobalGeneric* instr) { 2752 void LCodeGen::DoStoreGlobalGeneric(LStoreGlobalGeneric* instr) {
2745 ASSERT(ToRegister(instr->context()).is(rsi)); 2753 ASSERT(ToRegister(instr->context()).is(rsi));
2746 ASSERT(ToRegister(instr->global_object()).is(rdx)); 2754 ASSERT(ToRegister(instr->global_object()).is(rdx));
2747 ASSERT(ToRegister(instr->value()).is(rax)); 2755 ASSERT(ToRegister(instr->value()).is(rax));
2748 2756
2749 __ Move(rcx, instr->name()); 2757 __ Move(rcx, instr->name());
2750 Handle<Code> ic = (instr->strict_mode_flag() == kStrictMode) 2758 Handle<Code> ic = StoreIC::initialize_stub(isolate(),
2751 ? isolate()->builtins()->StoreIC_Initialize_Strict() 2759 instr->strict_mode_flag(),
2752 : isolate()->builtins()->StoreIC_Initialize(); 2760 CONTEXTUAL);
2753 CallCode(ic, RelocInfo::CODE_TARGET_CONTEXT, instr); 2761 CallCode(ic, RelocInfo::CODE_TARGET, instr);
2754 } 2762 }
2755 2763
2756 2764
2757 void LCodeGen::DoLoadContextSlot(LLoadContextSlot* instr) { 2765 void LCodeGen::DoLoadContextSlot(LLoadContextSlot* instr) {
2758 Register context = ToRegister(instr->context()); 2766 Register context = ToRegister(instr->context());
2759 Register result = ToRegister(instr->result()); 2767 Register result = ToRegister(instr->result());
2760 __ movq(result, ContextOperand(context, instr->slot_index())); 2768 __ movq(result, ContextOperand(context, instr->slot_index()));
2761 if (instr->hydrogen()->RequiresHoleCheck()) { 2769 if (instr->hydrogen()->RequiresHoleCheck()) {
2762 __ CompareRoot(result, Heap::kTheHoleValueRootIndex); 2770 __ CompareRoot(result, Heap::kTheHoleValueRootIndex);
2763 if (instr->hydrogen()->DeoptimizesOnHole()) { 2771 if (instr->hydrogen()->DeoptimizesOnHole()) {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
2850 __ Load(result, FieldOperand(object, offset), representation); 2858 __ Load(result, FieldOperand(object, offset), representation);
2851 } 2859 }
2852 2860
2853 2861
2854 void LCodeGen::DoLoadNamedGeneric(LLoadNamedGeneric* instr) { 2862 void LCodeGen::DoLoadNamedGeneric(LLoadNamedGeneric* instr) {
2855 ASSERT(ToRegister(instr->context()).is(rsi)); 2863 ASSERT(ToRegister(instr->context()).is(rsi));
2856 ASSERT(ToRegister(instr->object()).is(rax)); 2864 ASSERT(ToRegister(instr->object()).is(rax));
2857 ASSERT(ToRegister(instr->result()).is(rax)); 2865 ASSERT(ToRegister(instr->result()).is(rax));
2858 2866
2859 __ Move(rcx, instr->name()); 2867 __ Move(rcx, instr->name());
2860 Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize(); 2868 Handle<Code> ic = LoadIC::initialize_stub(isolate(), NOT_CONTEXTUAL);
2861 CallCode(ic, RelocInfo::CODE_TARGET, instr); 2869 CallCode(ic, RelocInfo::CODE_TARGET, instr);
2862 } 2870 }
2863 2871
2864 2872
2865 void LCodeGen::DoLoadFunctionPrototype(LLoadFunctionPrototype* instr) { 2873 void LCodeGen::DoLoadFunctionPrototype(LLoadFunctionPrototype* instr) {
2866 Register function = ToRegister(instr->function()); 2874 Register function = ToRegister(instr->function());
2867 Register result = ToRegister(instr->result()); 2875 Register result = ToRegister(instr->result());
2868 2876
2869 // Check that the function really is a function. 2877 // Check that the function really is a function.
2870 __ CmpObjectType(function, JS_FUNCTION_TYPE, result); 2878 __ CmpObjectType(function, JS_FUNCTION_TYPE, result);
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
3240 __ j(equal, &global_object, Label::kNear); 3248 __ j(equal, &global_object, Label::kNear);
3241 3249
3242 // The receiver should be a JS object. 3250 // The receiver should be a JS object.
3243 Condition is_smi = __ CheckSmi(receiver); 3251 Condition is_smi = __ CheckSmi(receiver);
3244 DeoptimizeIf(is_smi, instr->environment()); 3252 DeoptimizeIf(is_smi, instr->environment());
3245 __ CmpObjectType(receiver, FIRST_SPEC_OBJECT_TYPE, kScratchRegister); 3253 __ CmpObjectType(receiver, FIRST_SPEC_OBJECT_TYPE, kScratchRegister);
3246 DeoptimizeIf(below, instr->environment()); 3254 DeoptimizeIf(below, instr->environment());
3247 __ jmp(&receiver_ok, Label::kNear); 3255 __ jmp(&receiver_ok, Label::kNear);
3248 3256
3249 __ bind(&global_object); 3257 __ bind(&global_object);
3250 // TODO(kmillikin): We have a hydrogen value for the global object. See 3258 __ movq(receiver, FieldOperand(function, JSFunction::kContextOffset));
3251 // if it's better to use it than to explicitly fetch it from the context
3252 // here.
3253 __ movq(receiver, Operand(rbp, StandardFrameConstants::kContextOffset));
3254 __ movq(receiver, ContextOperand(receiver, Context::GLOBAL_OBJECT_INDEX));
3255 __ movq(receiver, 3259 __ movq(receiver,
3256 FieldOperand(receiver, JSGlobalObject::kGlobalReceiverOffset)); 3260 Operand(receiver, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX)));
3261 __ movq(receiver,
3262 FieldOperand(receiver, GlobalObject::kGlobalReceiverOffset));
3257 __ bind(&receiver_ok); 3263 __ bind(&receiver_ok);
3258 } 3264 }
3259 3265
3260 3266
3261 void LCodeGen::DoApplyArguments(LApplyArguments* instr) { 3267 void LCodeGen::DoApplyArguments(LApplyArguments* instr) {
3262 Register receiver = ToRegister(instr->receiver()); 3268 Register receiver = ToRegister(instr->receiver());
3263 Register function = ToRegister(instr->function()); 3269 Register function = ToRegister(instr->function());
3264 Register length = ToRegister(instr->length()); 3270 Register length = ToRegister(instr->length());
3265 Register elements = ToRegister(instr->elements()); 3271 Register elements = ToRegister(instr->elements());
3266 ASSERT(receiver.is(rax)); // Used for parameter count. 3272 ASSERT(receiver.is(rax)); // Used for parameter count.
(...skipping 23 matching lines...) Expand all
3290 __ j(not_zero, &loop); 3296 __ j(not_zero, &loop);
3291 3297
3292 // Invoke the function. 3298 // Invoke the function.
3293 __ bind(&invoke); 3299 __ bind(&invoke);
3294 ASSERT(instr->HasPointerMap()); 3300 ASSERT(instr->HasPointerMap());
3295 LPointerMap* pointers = instr->pointer_map(); 3301 LPointerMap* pointers = instr->pointer_map();
3296 SafepointGenerator safepoint_generator( 3302 SafepointGenerator safepoint_generator(
3297 this, pointers, Safepoint::kLazyDeopt); 3303 this, pointers, Safepoint::kLazyDeopt);
3298 ParameterCount actual(rax); 3304 ParameterCount actual(rax);
3299 __ InvokeFunction(function, actual, CALL_FUNCTION, 3305 __ InvokeFunction(function, actual, CALL_FUNCTION,
3300 safepoint_generator, CALL_AS_METHOD); 3306 safepoint_generator, CALL_AS_FUNCTION);
3301 } 3307 }
3302 3308
3303 3309
3304 void LCodeGen::DoPushArgument(LPushArgument* instr) { 3310 void LCodeGen::DoPushArgument(LPushArgument* instr) {
3305 LOperand* argument = instr->value(); 3311 LOperand* argument = instr->value();
3306 EmitPushTaggedOperand(argument); 3312 EmitPushTaggedOperand(argument);
3307 } 3313 }
3308 3314
3309 3315
3310 void LCodeGen::DoDrop(LDrop* instr) { 3316 void LCodeGen::DoDrop(LDrop* instr) {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
3409 } 3415 }
3410 } 3416 }
3411 3417
3412 3418
3413 void LCodeGen::DoCallConstantFunction(LCallConstantFunction* instr) { 3419 void LCodeGen::DoCallConstantFunction(LCallConstantFunction* instr) {
3414 ASSERT(ToRegister(instr->result()).is(rax)); 3420 ASSERT(ToRegister(instr->result()).is(rax));
3415 CallKnownFunction(instr->hydrogen()->function(), 3421 CallKnownFunction(instr->hydrogen()->function(),
3416 instr->hydrogen()->formal_parameter_count(), 3422 instr->hydrogen()->formal_parameter_count(),
3417 instr->arity(), 3423 instr->arity(),
3418 instr, 3424 instr,
3419 CALL_AS_METHOD, 3425 CALL_AS_FUNCTION,
3420 RDI_UNINITIALIZED); 3426 RDI_UNINITIALIZED);
3421 } 3427 }
3422 3428
3423 3429
3424 void LCodeGen::DoDeferredMathAbsTaggedHeapNumber(LMathAbs* instr) { 3430 void LCodeGen::DoDeferredMathAbsTaggedHeapNumber(LMathAbs* instr) {
3425 Register input_reg = ToRegister(instr->value()); 3431 Register input_reg = ToRegister(instr->value());
3426 __ CompareRoot(FieldOperand(input_reg, HeapObject::kMapOffset), 3432 __ CompareRoot(FieldOperand(input_reg, HeapObject::kMapOffset),
3427 Heap::kHeapNumberMapRootIndex); 3433 Heap::kHeapNumberMapRootIndex);
3428 DeoptimizeIf(not_equal, instr->environment()); 3434 DeoptimizeIf(not_equal, instr->environment());
3429 3435
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
3768 void LCodeGen::DoInvokeFunction(LInvokeFunction* instr) { 3774 void LCodeGen::DoInvokeFunction(LInvokeFunction* instr) {
3769 ASSERT(ToRegister(instr->context()).is(rsi)); 3775 ASSERT(ToRegister(instr->context()).is(rsi));
3770 ASSERT(ToRegister(instr->function()).is(rdi)); 3776 ASSERT(ToRegister(instr->function()).is(rdi));
3771 ASSERT(instr->HasPointerMap()); 3777 ASSERT(instr->HasPointerMap());
3772 3778
3773 Handle<JSFunction> known_function = instr->hydrogen()->known_function(); 3779 Handle<JSFunction> known_function = instr->hydrogen()->known_function();
3774 if (known_function.is_null()) { 3780 if (known_function.is_null()) {
3775 LPointerMap* pointers = instr->pointer_map(); 3781 LPointerMap* pointers = instr->pointer_map();
3776 SafepointGenerator generator(this, pointers, Safepoint::kLazyDeopt); 3782 SafepointGenerator generator(this, pointers, Safepoint::kLazyDeopt);
3777 ParameterCount count(instr->arity()); 3783 ParameterCount count(instr->arity());
3778 __ InvokeFunction(rdi, count, CALL_FUNCTION, generator, CALL_AS_METHOD); 3784 __ InvokeFunction(rdi, count, CALL_FUNCTION, generator, CALL_AS_FUNCTION);
3779 } else { 3785 } else {
3780 CallKnownFunction(known_function, 3786 CallKnownFunction(known_function,
3781 instr->hydrogen()->formal_parameter_count(), 3787 instr->hydrogen()->formal_parameter_count(),
3782 instr->arity(), 3788 instr->arity(),
3783 instr, 3789 instr,
3784 CALL_AS_METHOD, 3790 CALL_AS_FUNCTION,
3785 RDI_CONTAINS_TARGET); 3791 RDI_CONTAINS_TARGET);
3786 } 3792 }
3787 } 3793 }
3788 3794
3789 3795
3790 void LCodeGen::DoCallKeyed(LCallKeyed* instr) { 3796 void LCodeGen::DoCallKeyed(LCallKeyed* instr) {
3791 ASSERT(ToRegister(instr->context()).is(rsi)); 3797 ASSERT(ToRegister(instr->context()).is(rsi));
3792 ASSERT(ToRegister(instr->key()).is(rcx)); 3798 ASSERT(ToRegister(instr->key()).is(rcx));
3793 ASSERT(ToRegister(instr->result()).is(rax)); 3799 ASSERT(ToRegister(instr->result()).is(rax));
3794 3800
3795 int arity = instr->arity(); 3801 int arity = instr->arity();
3796 Handle<Code> ic = 3802 Handle<Code> ic =
3797 isolate()->stub_cache()->ComputeKeyedCallInitialize(arity); 3803 isolate()->stub_cache()->ComputeKeyedCallInitialize(arity);
3798 CallCode(ic, RelocInfo::CODE_TARGET, instr); 3804 CallCode(ic, RelocInfo::CODE_TARGET, instr);
3799 } 3805 }
3800 3806
3801 3807
3802 void LCodeGen::DoCallNamed(LCallNamed* instr) { 3808 void LCodeGen::DoCallNamed(LCallNamed* instr) {
3803 ASSERT(ToRegister(instr->context()).is(rsi)); 3809 ASSERT(ToRegister(instr->context()).is(rsi));
3804 ASSERT(ToRegister(instr->result()).is(rax)); 3810 ASSERT(ToRegister(instr->result()).is(rax));
3805 3811
3806 int arity = instr->arity(); 3812 int arity = instr->arity();
3807 RelocInfo::Mode mode = RelocInfo::CODE_TARGET;
3808 Handle<Code> ic = 3813 Handle<Code> ic =
3809 isolate()->stub_cache()->ComputeCallInitialize(arity, mode); 3814 isolate()->stub_cache()->ComputeCallInitialize(arity, NOT_CONTEXTUAL);
3810 __ Move(rcx, instr->name()); 3815 __ Move(rcx, instr->name());
3811 CallCode(ic, mode, instr); 3816 CallCode(ic, RelocInfo::CODE_TARGET, instr);
3812 } 3817 }
3813 3818
3814 3819
3815 void LCodeGen::DoCallFunction(LCallFunction* instr) { 3820 void LCodeGen::DoCallFunction(LCallFunction* instr) {
3816 ASSERT(ToRegister(instr->context()).is(rsi)); 3821 ASSERT(ToRegister(instr->context()).is(rsi));
3817 ASSERT(ToRegister(instr->function()).is(rdi)); 3822 ASSERT(ToRegister(instr->function()).is(rdi));
3818 ASSERT(ToRegister(instr->result()).is(rax)); 3823 ASSERT(ToRegister(instr->result()).is(rax));
3819 3824
3820 int arity = instr->arity(); 3825 int arity = instr->arity();
3821 CallFunctionStub stub(arity, NO_CALL_FUNCTION_FLAGS); 3826 CallFunctionStub stub(arity, NO_CALL_FUNCTION_FLAGS);
3822 if (instr->hydrogen()->IsTailCall()) { 3827 if (instr->hydrogen()->IsTailCall()) {
3823 if (NeedsEagerFrame()) __ leave(); 3828 if (NeedsEagerFrame()) __ leave();
3824 __ jmp(stub.GetCode(isolate()), RelocInfo::CODE_TARGET); 3829 __ jmp(stub.GetCode(isolate()), RelocInfo::CODE_TARGET);
3825 } else { 3830 } else {
3826 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); 3831 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr);
3827 } 3832 }
3828 } 3833 }
3829 3834
3830 3835
3831 void LCodeGen::DoCallGlobal(LCallGlobal* instr) { 3836 void LCodeGen::DoCallGlobal(LCallGlobal* instr) {
3832 ASSERT(ToRegister(instr->context()).is(rsi)); 3837 ASSERT(ToRegister(instr->context()).is(rsi));
3833 ASSERT(ToRegister(instr->result()).is(rax)); 3838 ASSERT(ToRegister(instr->result()).is(rax));
3834 int arity = instr->arity(); 3839 int arity = instr->arity();
3835 RelocInfo::Mode mode = RelocInfo::CODE_TARGET_CONTEXT;
3836 Handle<Code> ic = 3840 Handle<Code> ic =
3837 isolate()->stub_cache()->ComputeCallInitialize(arity, mode); 3841 isolate()->stub_cache()->ComputeCallInitialize(arity, CONTEXTUAL);
3838 __ Move(rcx, instr->name()); 3842 __ Move(rcx, instr->name());
3839 CallCode(ic, mode, instr); 3843 CallCode(ic, RelocInfo::CODE_TARGET, instr);
3840 } 3844 }
3841 3845
3842 3846
3843 void LCodeGen::DoCallKnownGlobal(LCallKnownGlobal* instr) { 3847 void LCodeGen::DoCallKnownGlobal(LCallKnownGlobal* instr) {
3844 ASSERT(ToRegister(instr->result()).is(rax)); 3848 ASSERT(ToRegister(instr->result()).is(rax));
3845 CallKnownFunction(instr->hydrogen()->target(), 3849 CallKnownFunction(instr->hydrogen()->target(),
3846 instr->hydrogen()->formal_parameter_count(), 3850 instr->hydrogen()->formal_parameter_count(),
3847 instr->arity(), 3851 instr->arity(),
3848 instr, 3852 instr,
3849 CALL_AS_FUNCTION, 3853 CALL_AS_FUNCTION,
(...skipping 20 matching lines...) Expand all
3870 ASSERT(ToRegister(instr->constructor()).is(rdi)); 3874 ASSERT(ToRegister(instr->constructor()).is(rdi));
3871 ASSERT(ToRegister(instr->result()).is(rax)); 3875 ASSERT(ToRegister(instr->result()).is(rax));
3872 3876
3873 __ Set(rax, instr->arity()); 3877 __ Set(rax, instr->arity());
3874 __ Move(rbx, instr->hydrogen()->property_cell()); 3878 __ Move(rbx, instr->hydrogen()->property_cell());
3875 ElementsKind kind = instr->hydrogen()->elements_kind(); 3879 ElementsKind kind = instr->hydrogen()->elements_kind();
3876 AllocationSiteOverrideMode override_mode = 3880 AllocationSiteOverrideMode override_mode =
3877 (AllocationSite::GetMode(kind) == TRACK_ALLOCATION_SITE) 3881 (AllocationSite::GetMode(kind) == TRACK_ALLOCATION_SITE)
3878 ? DISABLE_ALLOCATION_SITES 3882 ? DISABLE_ALLOCATION_SITES
3879 : DONT_OVERRIDE; 3883 : DONT_OVERRIDE;
3880 ContextCheckMode context_mode = CONTEXT_CHECK_NOT_REQUIRED;
3881 3884
3882 if (instr->arity() == 0) { 3885 if (instr->arity() == 0) {
3883 ArrayNoArgumentConstructorStub stub(kind, context_mode, override_mode); 3886 ArrayNoArgumentConstructorStub stub(kind, override_mode);
3884 CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr); 3887 CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr);
3885 } else if (instr->arity() == 1) { 3888 } else if (instr->arity() == 1) {
3886 Label done; 3889 Label done;
3887 if (IsFastPackedElementsKind(kind)) { 3890 if (IsFastPackedElementsKind(kind)) {
3888 Label packed_case; 3891 Label packed_case;
3889 // We might need a change here 3892 // We might need a change here
3890 // look at the first argument 3893 // look at the first argument
3891 __ movq(rcx, Operand(rsp, 0)); 3894 __ movq(rcx, Operand(rsp, 0));
3892 __ testq(rcx, rcx); 3895 __ testq(rcx, rcx);
3893 __ j(zero, &packed_case, Label::kNear); 3896 __ j(zero, &packed_case, Label::kNear);
3894 3897
3895 ElementsKind holey_kind = GetHoleyElementsKind(kind); 3898 ElementsKind holey_kind = GetHoleyElementsKind(kind);
3896 ArraySingleArgumentConstructorStub stub(holey_kind, context_mode, 3899 ArraySingleArgumentConstructorStub stub(holey_kind, override_mode);
3897 override_mode);
3898 CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr); 3900 CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr);
3899 __ jmp(&done, Label::kNear); 3901 __ jmp(&done, Label::kNear);
3900 __ bind(&packed_case); 3902 __ bind(&packed_case);
3901 } 3903 }
3902 3904
3903 ArraySingleArgumentConstructorStub stub(kind, context_mode, override_mode); 3905 ArraySingleArgumentConstructorStub stub(kind, override_mode);
3904 CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr); 3906 CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr);
3905 __ bind(&done); 3907 __ bind(&done);
3906 } else { 3908 } else {
3907 ArrayNArgumentsConstructorStub stub(kind, context_mode, override_mode); 3909 ArrayNArgumentsConstructorStub stub(kind, override_mode);
3908 CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr); 3910 CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr);
3909 } 3911 }
3910 } 3912 }
3911 3913
3912 3914
3913 void LCodeGen::DoCallRuntime(LCallRuntime* instr) { 3915 void LCodeGen::DoCallRuntime(LCallRuntime* instr) {
3914 ASSERT(ToRegister(instr->context()).is(rsi)); 3916 ASSERT(ToRegister(instr->context()).is(rsi));
3915 CallRuntime(instr->function(), instr->arity(), instr, instr->save_doubles()); 3917 CallRuntime(instr->function(), instr->arity(), instr, instr->save_doubles());
3916 } 3918 }
3917 3919
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
4068 } 4070 }
4069 } 4071 }
4070 4072
4071 4073
4072 void LCodeGen::DoStoreNamedGeneric(LStoreNamedGeneric* instr) { 4074 void LCodeGen::DoStoreNamedGeneric(LStoreNamedGeneric* instr) {
4073 ASSERT(ToRegister(instr->context()).is(rsi)); 4075 ASSERT(ToRegister(instr->context()).is(rsi));
4074 ASSERT(ToRegister(instr->object()).is(rdx)); 4076 ASSERT(ToRegister(instr->object()).is(rdx));
4075 ASSERT(ToRegister(instr->value()).is(rax)); 4077 ASSERT(ToRegister(instr->value()).is(rax));
4076 4078
4077 __ Move(rcx, instr->hydrogen()->name()); 4079 __ Move(rcx, instr->hydrogen()->name());
4078 Handle<Code> ic = (instr->strict_mode_flag() == kStrictMode) 4080 Handle<Code> ic = StoreIC::initialize_stub(isolate(),
4079 ? isolate()->builtins()->StoreIC_Initialize_Strict() 4081 instr->strict_mode_flag(),
4080 : isolate()->builtins()->StoreIC_Initialize(); 4082 NOT_CONTEXTUAL);
4081 CallCode(ic, RelocInfo::CODE_TARGET, instr); 4083 CallCode(ic, RelocInfo::CODE_TARGET, instr);
4082 } 4084 }
4083 4085
4084 4086
4085 void LCodeGen::ApplyCheckIf(Condition cc, LBoundsCheck* check) { 4087 void LCodeGen::ApplyCheckIf(Condition cc, LBoundsCheck* check) {
4086 if (FLAG_debug_code && check->hydrogen()->skip_check()) { 4088 if (FLAG_debug_code && check->hydrogen()->skip_check()) {
4087 Label done; 4089 Label done;
4088 __ j(NegateCondition(cc), &done, Label::kNear); 4090 __ j(NegateCondition(cc), &done, Label::kNear);
4089 __ int3(); 4091 __ int3();
4090 __ bind(&done); 4092 __ bind(&done);
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
4344 Handle<Map> from_map = instr->original_map(); 4346 Handle<Map> from_map = instr->original_map();
4345 Handle<Map> to_map = instr->transitioned_map(); 4347 Handle<Map> to_map = instr->transitioned_map();
4346 ElementsKind from_kind = instr->from_kind(); 4348 ElementsKind from_kind = instr->from_kind();
4347 ElementsKind to_kind = instr->to_kind(); 4349 ElementsKind to_kind = instr->to_kind();
4348 4350
4349 Label not_applicable; 4351 Label not_applicable;
4350 __ Cmp(FieldOperand(object_reg, HeapObject::kMapOffset), from_map); 4352 __ Cmp(FieldOperand(object_reg, HeapObject::kMapOffset), from_map);
4351 __ j(not_equal, &not_applicable); 4353 __ j(not_equal, &not_applicable);
4352 if (IsSimpleMapChangeTransition(from_kind, to_kind)) { 4354 if (IsSimpleMapChangeTransition(from_kind, to_kind)) {
4353 Register new_map_reg = ToRegister(instr->new_map_temp()); 4355 Register new_map_reg = ToRegister(instr->new_map_temp());
4354 __ movq(new_map_reg, to_map, RelocInfo::EMBEDDED_OBJECT); 4356 __ Move(new_map_reg, to_map, RelocInfo::EMBEDDED_OBJECT);
4355 __ movq(FieldOperand(object_reg, HeapObject::kMapOffset), new_map_reg); 4357 __ movq(FieldOperand(object_reg, HeapObject::kMapOffset), new_map_reg);
4356 // Write barrier. 4358 // Write barrier.
4357 ASSERT_NE(instr->temp(), NULL); 4359 ASSERT_NE(instr->temp(), NULL);
4358 __ RecordWriteField(object_reg, HeapObject::kMapOffset, new_map_reg, 4360 __ RecordWriteField(object_reg, HeapObject::kMapOffset, new_map_reg,
4359 ToRegister(instr->temp()), kDontSaveFPRegs); 4361 ToRegister(instr->temp()), kDontSaveFPRegs);
4360 } else { 4362 } else {
4361 ASSERT(ToRegister(instr->context()).is(rsi)); 4363 ASSERT(ToRegister(instr->context()).is(rsi));
4362 PushSafepointRegistersScope scope(this); 4364 PushSafepointRegistersScope scope(this);
4363 if (!object_reg.is(rax)) { 4365 if (!object_reg.is(rax)) {
4364 __ movq(rax, object_reg); 4366 __ movq(rax, object_reg);
(...skipping 1269 matching lines...) Expand 10 before | Expand all | Expand 10 after
5634 FixedArray::kHeaderSize - kPointerSize)); 5636 FixedArray::kHeaderSize - kPointerSize));
5635 __ bind(&done); 5637 __ bind(&done);
5636 } 5638 }
5637 5639
5638 5640
5639 #undef __ 5641 #undef __
5640 5642
5641 } } // namespace v8::internal 5643 } } // namespace v8::internal
5642 5644
5643 #endif // V8_TARGET_ARCH_X64 5645 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/ic-x64.cc ('k') | src/x64/lithium-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698