OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_IA32 | 7 #if V8_TARGET_ARCH_IA32 |
8 | 8 |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
| 10 #include "src/code-factory.h" |
10 #include "src/code-stubs.h" | 11 #include "src/code-stubs.h" |
11 #include "src/codegen.h" | 12 #include "src/codegen.h" |
12 #include "src/deoptimizer.h" | 13 #include "src/deoptimizer.h" |
13 #include "src/hydrogen-osr.h" | 14 #include "src/hydrogen-osr.h" |
14 #include "src/ia32/lithium-codegen-ia32.h" | 15 #include "src/ia32/lithium-codegen-ia32.h" |
15 #include "src/ic/stub-cache.h" | 16 #include "src/ic/stub-cache.h" |
16 | 17 |
17 namespace v8 { | 18 namespace v8 { |
18 namespace internal { | 19 namespace internal { |
19 | 20 |
(...skipping 2006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2026 } | 2027 } |
2027 } | 2028 } |
2028 | 2029 |
2029 | 2030 |
2030 void LCodeGen::DoArithmeticT(LArithmeticT* instr) { | 2031 void LCodeGen::DoArithmeticT(LArithmeticT* instr) { |
2031 DCHECK(ToRegister(instr->context()).is(esi)); | 2032 DCHECK(ToRegister(instr->context()).is(esi)); |
2032 DCHECK(ToRegister(instr->left()).is(edx)); | 2033 DCHECK(ToRegister(instr->left()).is(edx)); |
2033 DCHECK(ToRegister(instr->right()).is(eax)); | 2034 DCHECK(ToRegister(instr->right()).is(eax)); |
2034 DCHECK(ToRegister(instr->result()).is(eax)); | 2035 DCHECK(ToRegister(instr->result()).is(eax)); |
2035 | 2036 |
2036 BinaryOpICStub stub(isolate(), instr->op(), NO_OVERWRITE); | 2037 Handle<Code> code = |
2037 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); | 2038 CodeFactory::BinaryOpIC(isolate(), instr->op(), NO_OVERWRITE).code(); |
| 2039 CallCode(code, RelocInfo::CODE_TARGET, instr); |
2038 } | 2040 } |
2039 | 2041 |
2040 | 2042 |
2041 template<class InstrType> | 2043 template<class InstrType> |
2042 void LCodeGen::EmitBranch(InstrType instr, Condition cc) { | 2044 void LCodeGen::EmitBranch(InstrType instr, Condition cc) { |
2043 int left_block = instr->TrueDestination(chunk_); | 2045 int left_block = instr->TrueDestination(chunk_); |
2044 int right_block = instr->FalseDestination(chunk_); | 2046 int right_block = instr->FalseDestination(chunk_); |
2045 | 2047 |
2046 int next_block = GetNextEmittedBlock(); | 2048 int next_block = GetNextEmittedBlock(); |
2047 | 2049 |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2452 default: | 2454 default: |
2453 UNREACHABLE(); | 2455 UNREACHABLE(); |
2454 return no_condition; | 2456 return no_condition; |
2455 } | 2457 } |
2456 } | 2458 } |
2457 | 2459 |
2458 | 2460 |
2459 void LCodeGen::DoStringCompareAndBranch(LStringCompareAndBranch* instr) { | 2461 void LCodeGen::DoStringCompareAndBranch(LStringCompareAndBranch* instr) { |
2460 Token::Value op = instr->op(); | 2462 Token::Value op = instr->op(); |
2461 | 2463 |
2462 Handle<Code> ic = CompareIC::GetUninitialized(isolate(), op); | 2464 Handle<Code> ic = CodeFactory::CompareIC(isolate(), op).code(); |
2463 CallCode(ic, RelocInfo::CODE_TARGET, instr); | 2465 CallCode(ic, RelocInfo::CODE_TARGET, instr); |
2464 | 2466 |
2465 Condition condition = ComputeCompareCondition(op); | 2467 Condition condition = ComputeCompareCondition(op); |
2466 __ test(eax, Operand(eax)); | 2468 __ test(eax, Operand(eax)); |
2467 | 2469 |
2468 EmitBranch(instr, condition); | 2470 EmitBranch(instr, condition); |
2469 } | 2471 } |
2470 | 2472 |
2471 | 2473 |
2472 static InstanceType TestType(HHasInstanceTypeAndBranch* instr) { | 2474 static InstanceType TestType(HHasInstanceTypeAndBranch* instr) { |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2723 safepoints_.RecordLazyDeoptimizationIndex(env->deoptimization_index()); | 2725 safepoints_.RecordLazyDeoptimizationIndex(env->deoptimization_index()); |
2724 | 2726 |
2725 // Put the result value into the eax slot and restore all registers. | 2727 // Put the result value into the eax slot and restore all registers. |
2726 __ StoreToSafepointRegisterSlot(eax, eax); | 2728 __ StoreToSafepointRegisterSlot(eax, eax); |
2727 } | 2729 } |
2728 | 2730 |
2729 | 2731 |
2730 void LCodeGen::DoCmpT(LCmpT* instr) { | 2732 void LCodeGen::DoCmpT(LCmpT* instr) { |
2731 Token::Value op = instr->op(); | 2733 Token::Value op = instr->op(); |
2732 | 2734 |
2733 Handle<Code> ic = CompareIC::GetUninitialized(isolate(), op); | 2735 Handle<Code> ic = CodeFactory::CompareIC(isolate(), op).code(); |
2734 CallCode(ic, RelocInfo::CODE_TARGET, instr); | 2736 CallCode(ic, RelocInfo::CODE_TARGET, instr); |
2735 | 2737 |
2736 Condition condition = ComputeCompareCondition(op); | 2738 Condition condition = ComputeCompareCondition(op); |
2737 Label true_value, done; | 2739 Label true_value, done; |
2738 __ test(eax, Operand(eax)); | 2740 __ test(eax, Operand(eax)); |
2739 __ j(condition, &true_value, Label::kNear); | 2741 __ j(condition, &true_value, Label::kNear); |
2740 __ mov(ToRegister(instr->result()), factory()->false_value()); | 2742 __ mov(ToRegister(instr->result()), factory()->false_value()); |
2741 __ jmp(&done, Label::kNear); | 2743 __ jmp(&done, Label::kNear); |
2742 __ bind(&true_value); | 2744 __ bind(&true_value); |
2743 __ mov(ToRegister(instr->result()), factory()->true_value()); | 2745 __ mov(ToRegister(instr->result()), factory()->true_value()); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2847 DCHECK(ToRegister(instr->context()).is(esi)); | 2849 DCHECK(ToRegister(instr->context()).is(esi)); |
2848 DCHECK(ToRegister(instr->global_object()) | 2850 DCHECK(ToRegister(instr->global_object()) |
2849 .is(LoadDescriptor::ReceiverRegister())); | 2851 .is(LoadDescriptor::ReceiverRegister())); |
2850 DCHECK(ToRegister(instr->result()).is(eax)); | 2852 DCHECK(ToRegister(instr->result()).is(eax)); |
2851 | 2853 |
2852 __ mov(LoadDescriptor::NameRegister(), instr->name()); | 2854 __ mov(LoadDescriptor::NameRegister(), instr->name()); |
2853 if (FLAG_vector_ics) { | 2855 if (FLAG_vector_ics) { |
2854 EmitVectorLoadICRegisters<LLoadGlobalGeneric>(instr); | 2856 EmitVectorLoadICRegisters<LLoadGlobalGeneric>(instr); |
2855 } | 2857 } |
2856 ContextualMode mode = instr->for_typeof() ? NOT_CONTEXTUAL : CONTEXTUAL; | 2858 ContextualMode mode = instr->for_typeof() ? NOT_CONTEXTUAL : CONTEXTUAL; |
2857 Handle<Code> ic = LoadIC::initialize_stub(isolate(), mode); | 2859 Handle<Code> ic = CodeFactory::LoadIC(isolate(), mode).code(); |
2858 CallCode(ic, RelocInfo::CODE_TARGET, instr); | 2860 CallCode(ic, RelocInfo::CODE_TARGET, instr); |
2859 } | 2861 } |
2860 | 2862 |
2861 | 2863 |
2862 void LCodeGen::DoStoreGlobalCell(LStoreGlobalCell* instr) { | 2864 void LCodeGen::DoStoreGlobalCell(LStoreGlobalCell* instr) { |
2863 Register value = ToRegister(instr->value()); | 2865 Register value = ToRegister(instr->value()); |
2864 Handle<PropertyCell> cell_handle = instr->hydrogen()->cell().handle(); | 2866 Handle<PropertyCell> cell_handle = instr->hydrogen()->cell().handle(); |
2865 | 2867 |
2866 // If the cell we are storing to contains the hole it could have | 2868 // If the cell we are storing to contains the hole it could have |
2867 // been deleted from the property dictionary. In that case, we need | 2869 // been deleted from the property dictionary. In that case, we need |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2983 | 2985 |
2984 void LCodeGen::DoLoadNamedGeneric(LLoadNamedGeneric* instr) { | 2986 void LCodeGen::DoLoadNamedGeneric(LLoadNamedGeneric* instr) { |
2985 DCHECK(ToRegister(instr->context()).is(esi)); | 2987 DCHECK(ToRegister(instr->context()).is(esi)); |
2986 DCHECK(ToRegister(instr->object()).is(LoadDescriptor::ReceiverRegister())); | 2988 DCHECK(ToRegister(instr->object()).is(LoadDescriptor::ReceiverRegister())); |
2987 DCHECK(ToRegister(instr->result()).is(eax)); | 2989 DCHECK(ToRegister(instr->result()).is(eax)); |
2988 | 2990 |
2989 __ mov(LoadDescriptor::NameRegister(), instr->name()); | 2991 __ mov(LoadDescriptor::NameRegister(), instr->name()); |
2990 if (FLAG_vector_ics) { | 2992 if (FLAG_vector_ics) { |
2991 EmitVectorLoadICRegisters<LLoadNamedGeneric>(instr); | 2993 EmitVectorLoadICRegisters<LLoadNamedGeneric>(instr); |
2992 } | 2994 } |
2993 Handle<Code> ic = LoadIC::initialize_stub(isolate(), NOT_CONTEXTUAL); | 2995 Handle<Code> ic = CodeFactory::LoadIC(isolate(), NOT_CONTEXTUAL).code(); |
2994 CallCode(ic, RelocInfo::CODE_TARGET, instr); | 2996 CallCode(ic, RelocInfo::CODE_TARGET, instr); |
2995 } | 2997 } |
2996 | 2998 |
2997 | 2999 |
2998 void LCodeGen::DoLoadFunctionPrototype(LLoadFunctionPrototype* instr) { | 3000 void LCodeGen::DoLoadFunctionPrototype(LLoadFunctionPrototype* instr) { |
2999 Register function = ToRegister(instr->function()); | 3001 Register function = ToRegister(instr->function()); |
3000 Register temp = ToRegister(instr->temp()); | 3002 Register temp = ToRegister(instr->temp()); |
3001 Register result = ToRegister(instr->result()); | 3003 Register result = ToRegister(instr->result()); |
3002 | 3004 |
3003 // Get the prototype or initial map from the function. | 3005 // Get the prototype or initial map from the function. |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3209 | 3211 |
3210 void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) { | 3212 void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) { |
3211 DCHECK(ToRegister(instr->context()).is(esi)); | 3213 DCHECK(ToRegister(instr->context()).is(esi)); |
3212 DCHECK(ToRegister(instr->object()).is(LoadDescriptor::ReceiverRegister())); | 3214 DCHECK(ToRegister(instr->object()).is(LoadDescriptor::ReceiverRegister())); |
3213 DCHECK(ToRegister(instr->key()).is(LoadDescriptor::NameRegister())); | 3215 DCHECK(ToRegister(instr->key()).is(LoadDescriptor::NameRegister())); |
3214 | 3216 |
3215 if (FLAG_vector_ics) { | 3217 if (FLAG_vector_ics) { |
3216 EmitVectorLoadICRegisters<LLoadKeyedGeneric>(instr); | 3218 EmitVectorLoadICRegisters<LLoadKeyedGeneric>(instr); |
3217 } | 3219 } |
3218 | 3220 |
3219 Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize(); | 3221 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate()).code(); |
3220 CallCode(ic, RelocInfo::CODE_TARGET, instr); | 3222 CallCode(ic, RelocInfo::CODE_TARGET, instr); |
3221 } | 3223 } |
3222 | 3224 |
3223 | 3225 |
3224 void LCodeGen::DoArgumentsElements(LArgumentsElements* instr) { | 3226 void LCodeGen::DoArgumentsElements(LArgumentsElements* instr) { |
3225 Register result = ToRegister(instr->result()); | 3227 Register result = ToRegister(instr->result()); |
3226 | 3228 |
3227 if (instr->hydrogen()->from_inlined()) { | 3229 if (instr->hydrogen()->from_inlined()) { |
3228 __ lea(result, Operand(esp, -2 * kPointerSize)); | 3230 __ lea(result, Operand(esp, -2 * kPointerSize)); |
3229 } else { | 3231 } else { |
(...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4275 } | 4277 } |
4276 } | 4278 } |
4277 | 4279 |
4278 | 4280 |
4279 void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) { | 4281 void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) { |
4280 DCHECK(ToRegister(instr->context()).is(esi)); | 4282 DCHECK(ToRegister(instr->context()).is(esi)); |
4281 DCHECK(ToRegister(instr->object()).is(StoreDescriptor::ReceiverRegister())); | 4283 DCHECK(ToRegister(instr->object()).is(StoreDescriptor::ReceiverRegister())); |
4282 DCHECK(ToRegister(instr->key()).is(StoreDescriptor::NameRegister())); | 4284 DCHECK(ToRegister(instr->key()).is(StoreDescriptor::NameRegister())); |
4283 DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister())); | 4285 DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister())); |
4284 | 4286 |
4285 Handle<Code> ic = instr->strict_mode() == STRICT | 4287 Handle<Code> ic = |
4286 ? isolate()->builtins()->KeyedStoreIC_Initialize_Strict() | 4288 CodeFactory::KeyedStoreIC(isolate(), instr->strict_mode()).code(); |
4287 : isolate()->builtins()->KeyedStoreIC_Initialize(); | |
4288 CallCode(ic, RelocInfo::CODE_TARGET, instr); | 4289 CallCode(ic, RelocInfo::CODE_TARGET, instr); |
4289 } | 4290 } |
4290 | 4291 |
4291 | 4292 |
4292 void LCodeGen::DoTrapAllocationMemento(LTrapAllocationMemento* instr) { | 4293 void LCodeGen::DoTrapAllocationMemento(LTrapAllocationMemento* instr) { |
4293 Register object = ToRegister(instr->object()); | 4294 Register object = ToRegister(instr->object()); |
4294 Register temp = ToRegister(instr->temp()); | 4295 Register temp = ToRegister(instr->temp()); |
4295 Label no_memento_found; | 4296 Label no_memento_found; |
4296 __ TestJSArrayForAllocationMemento(object, temp, &no_memento_found); | 4297 __ TestJSArrayForAllocationMemento(object, temp, &no_memento_found); |
4297 DeoptimizeIf(equal, instr->environment()); | 4298 DeoptimizeIf(equal, instr->environment()); |
(...skipping 1398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5696 CallRuntime(Runtime::kPushBlockContext, 2, instr); | 5697 CallRuntime(Runtime::kPushBlockContext, 2, instr); |
5697 RecordSafepoint(Safepoint::kNoLazyDeopt); | 5698 RecordSafepoint(Safepoint::kNoLazyDeopt); |
5698 } | 5699 } |
5699 | 5700 |
5700 | 5701 |
5701 #undef __ | 5702 #undef __ |
5702 | 5703 |
5703 } } // namespace v8::internal | 5704 } } // namespace v8::internal |
5704 | 5705 |
5705 #endif // V8_TARGET_ARCH_IA32 | 5706 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |