| 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/code-stubs.h" | 5 #include "src/code-stubs.h" |
| 6 | 6 |
| 7 #include <sstream> | 7 #include <sstream> |
| 8 | 8 |
| 9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
| 10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
| 11 #include "src/code-stub-assembler.h" | 11 #include "src/code-stub-assembler.h" |
| 12 #include "src/factory.h" | 12 #include "src/factory.h" |
| 13 #include "src/gdb-jit.h" | 13 #include "src/gdb-jit.h" |
| 14 #include "src/ic/handler-compiler.h" | 14 #include "src/ic/handler-compiler.h" |
| 15 #include "src/ic/ic.h" | 15 #include "src/ic/ic.h" |
| 16 #include "src/macro-assembler.h" | 16 #include "src/macro-assembler.h" |
| 17 #include "src/parsing/parser.h" | 17 #include "src/parsing/parser.h" |
| 18 | 18 |
| 19 namespace v8 { | 19 namespace v8 { |
| 20 namespace internal { | 20 namespace internal { |
| 21 | 21 |
| 22 | 22 |
| 23 RUNTIME_FUNCTION(UnexpectedStubMiss) { | 23 RUNTIME_FUNCTION(UnexpectedStubMiss) { |
| 24 FATAL("Unexpected deopt of a stub"); | 24 FATAL("Unexpected deopt of a stub"); |
| 25 return Smi::FromInt(0); | 25 return Smi::FromInt(0); |
| 26 } | 26 } |
| 27 | 27 |
| 28 | |
| 29 CodeStubDescriptor::CodeStubDescriptor(CodeStub* stub) | 28 CodeStubDescriptor::CodeStubDescriptor(CodeStub* stub) |
| 30 : call_descriptor_(stub->GetCallInterfaceDescriptor()), | 29 : isolate_(stub->isolate()), |
| 30 call_descriptor_(stub->GetCallInterfaceDescriptor()), |
| 31 stack_parameter_count_(no_reg), | 31 stack_parameter_count_(no_reg), |
| 32 hint_stack_parameter_count_(-1), | 32 hint_stack_parameter_count_(-1), |
| 33 function_mode_(NOT_JS_FUNCTION_STUB_MODE), | 33 function_mode_(NOT_JS_FUNCTION_STUB_MODE), |
| 34 deoptimization_handler_(NULL), | 34 deoptimization_handler_(NULL), |
| 35 miss_handler_(), | 35 miss_handler_(), |
| 36 has_miss_handler_(false) { | 36 has_miss_handler_(false) { |
| 37 stub->InitializeDescriptor(this); | 37 stub->InitializeDescriptor(this); |
| 38 } | 38 } |
| 39 | 39 |
| 40 | |
| 41 CodeStubDescriptor::CodeStubDescriptor(Isolate* isolate, uint32_t stub_key) | 40 CodeStubDescriptor::CodeStubDescriptor(Isolate* isolate, uint32_t stub_key) |
| 42 : stack_parameter_count_(no_reg), | 41 : isolate_(isolate), |
| 42 stack_parameter_count_(no_reg), |
| 43 hint_stack_parameter_count_(-1), | 43 hint_stack_parameter_count_(-1), |
| 44 function_mode_(NOT_JS_FUNCTION_STUB_MODE), | 44 function_mode_(NOT_JS_FUNCTION_STUB_MODE), |
| 45 deoptimization_handler_(NULL), | 45 deoptimization_handler_(NULL), |
| 46 miss_handler_(), | 46 miss_handler_(), |
| 47 has_miss_handler_(false) { | 47 has_miss_handler_(false) { |
| 48 CodeStub::InitializeDescriptor(isolate, stub_key, this); | 48 CodeStub::InitializeDescriptor(isolate, stub_key, this); |
| 49 } | 49 } |
| 50 | 50 |
| 51 | 51 |
| 52 void CodeStubDescriptor::Initialize(Address deoptimization_handler, | 52 void CodeStubDescriptor::Initialize(Address deoptimization_handler, |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 HandleScope scope(isolate); | 263 HandleScope scope(isolate); |
| 264 Handle<Code> code; | 264 Handle<Code> code; |
| 265 void** value_out = reinterpret_cast<void**>(&code); | 265 void** value_out = reinterpret_cast<void**>(&code); |
| 266 Dispatch(isolate, key, value_out, &GetCodeDispatchCall); | 266 Dispatch(isolate, key, value_out, &GetCodeDispatchCall); |
| 267 return scope.CloseAndEscape(code); | 267 return scope.CloseAndEscape(code); |
| 268 } | 268 } |
| 269 | 269 |
| 270 | 270 |
| 271 // static | 271 // static |
| 272 void BinaryOpICStub::GenerateAheadOfTime(Isolate* isolate) { | 272 void BinaryOpICStub::GenerateAheadOfTime(Isolate* isolate) { |
| 273 if (FLAG_minimal) return; |
| 273 // Generate the uninitialized versions of the stub. | 274 // Generate the uninitialized versions of the stub. |
| 274 for (int op = Token::BIT_OR; op <= Token::MOD; ++op) { | 275 for (int op = Token::BIT_OR; op <= Token::MOD; ++op) { |
| 275 BinaryOpICStub stub(isolate, static_cast<Token::Value>(op)); | 276 BinaryOpICStub stub(isolate, static_cast<Token::Value>(op)); |
| 276 stub.GetCode(); | 277 stub.GetCode(); |
| 277 } | 278 } |
| 278 | 279 |
| 279 // Generate special versions of the stub. | 280 // Generate special versions of the stub. |
| 280 BinaryOpICState::GenerateAheadOfTime(isolate, &GenerateAheadOfTime); | 281 BinaryOpICState::GenerateAheadOfTime(isolate, &GenerateAheadOfTime); |
| 281 } | 282 } |
| 282 | 283 |
| 283 | 284 |
| 284 void BinaryOpICStub::PrintState(std::ostream& os) const { // NOLINT | 285 void BinaryOpICStub::PrintState(std::ostream& os) const { // NOLINT |
| 285 os << state(); | 286 os << state(); |
| 286 } | 287 } |
| 287 | 288 |
| 288 | 289 |
| 289 // static | 290 // static |
| 290 void BinaryOpICStub::GenerateAheadOfTime(Isolate* isolate, | 291 void BinaryOpICStub::GenerateAheadOfTime(Isolate* isolate, |
| 291 const BinaryOpICState& state) { | 292 const BinaryOpICState& state) { |
| 293 if (FLAG_minimal) return; |
| 292 BinaryOpICStub stub(isolate, state); | 294 BinaryOpICStub stub(isolate, state); |
| 293 stub.GetCode(); | 295 stub.GetCode(); |
| 294 } | 296 } |
| 295 | 297 |
| 296 | 298 |
| 297 // static | 299 // static |
| 298 void BinaryOpICWithAllocationSiteStub::GenerateAheadOfTime(Isolate* isolate) { | 300 void BinaryOpICWithAllocationSiteStub::GenerateAheadOfTime(Isolate* isolate) { |
| 299 // Generate special versions of the stub. | 301 // Generate special versions of the stub. |
| 300 BinaryOpICState::GenerateAheadOfTime(isolate, &GenerateAheadOfTime); | 302 BinaryOpICState::GenerateAheadOfTime(isolate, &GenerateAheadOfTime); |
| 301 } | 303 } |
| (...skipping 3781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4083 | 4085 |
| 4084 void ElementsTransitionAndStoreStub::InitializeDescriptor( | 4086 void ElementsTransitionAndStoreStub::InitializeDescriptor( |
| 4085 CodeStubDescriptor* descriptor) { | 4087 CodeStubDescriptor* descriptor) { |
| 4086 descriptor->Initialize( | 4088 descriptor->Initialize( |
| 4087 FUNCTION_ADDR(Runtime_ElementsTransitionAndStoreIC_Miss)); | 4089 FUNCTION_ADDR(Runtime_ElementsTransitionAndStoreIC_Miss)); |
| 4088 } | 4090 } |
| 4089 | 4091 |
| 4090 | 4092 |
| 4091 void ToObjectStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { | 4093 void ToObjectStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { |
| 4092 descriptor->Initialize(Runtime::FunctionForId(Runtime::kToObject)->entry); | 4094 descriptor->Initialize(Runtime::FunctionForId(Runtime::kToObject)->entry); |
| 4095 descriptor->SetMissHandler(Runtime::kToObject); |
| 4093 } | 4096 } |
| 4094 | 4097 |
| 4095 void StoreTransitionStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { | 4098 void StoreTransitionStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { |
| 4096 descriptor->Initialize( | 4099 descriptor->Initialize( |
| 4097 FUNCTION_ADDR(Runtime_TransitionStoreIC_MissFromStubFailure)); | 4100 FUNCTION_ADDR(Runtime_TransitionStoreIC_MissFromStubFailure)); |
| 4098 } | 4101 } |
| 4099 | 4102 |
| 4100 void TypeofStub::InitializeDescriptor(CodeStubDescriptor* descriptor) {} | 4103 void TypeofStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { |
| 4104 descriptor->SetMissHandler(Runtime::kTypeof); |
| 4105 } |
| 4101 | 4106 |
| 4102 void NumberToStringStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { | 4107 void NumberToStringStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { |
| 4103 descriptor->Initialize( | 4108 descriptor->Initialize( |
| 4104 Runtime::FunctionForId(Runtime::kNumberToString)->entry); | 4109 Runtime::FunctionForId(Runtime::kNumberToString)->entry); |
| 4110 descriptor->SetMissHandler(Runtime::kNumberToString); |
| 4105 } | 4111 } |
| 4106 | 4112 |
| 4107 | 4113 |
| 4108 void FastCloneRegExpStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { | 4114 void FastCloneRegExpStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { |
| 4109 FastCloneRegExpDescriptor call_descriptor(isolate()); | 4115 FastCloneRegExpDescriptor call_descriptor(isolate()); |
| 4110 descriptor->Initialize( | 4116 descriptor->Initialize( |
| 4111 Runtime::FunctionForId(Runtime::kCreateRegExpLiteral)->entry); | 4117 Runtime::FunctionForId(Runtime::kCreateRegExpLiteral)->entry); |
| 4118 descriptor->SetMissHandler(Runtime::kCreateRegExpLiteral); |
| 4112 } | 4119 } |
| 4113 | 4120 |
| 4114 | 4121 |
| 4115 void FastCloneShallowArrayStub::InitializeDescriptor( | 4122 void FastCloneShallowArrayStub::InitializeDescriptor( |
| 4116 CodeStubDescriptor* descriptor) { | 4123 CodeStubDescriptor* descriptor) { |
| 4117 FastCloneShallowArrayDescriptor call_descriptor(isolate()); | 4124 FastCloneShallowArrayDescriptor call_descriptor(isolate()); |
| 4118 descriptor->Initialize( | 4125 descriptor->Initialize( |
| 4119 Runtime::FunctionForId(Runtime::kCreateArrayLiteralStubBailout)->entry); | 4126 Runtime::FunctionForId(Runtime::kCreateArrayLiteralStubBailout)->entry); |
| 4127 descriptor->SetMissHandler(Runtime::kCreateArrayLiteralStubBailout); |
| 4120 } | 4128 } |
| 4121 | 4129 |
| 4122 | |
| 4123 void RegExpConstructResultStub::InitializeDescriptor( | 4130 void RegExpConstructResultStub::InitializeDescriptor( |
| 4124 CodeStubDescriptor* descriptor) { | 4131 CodeStubDescriptor* descriptor) { |
| 4125 descriptor->Initialize( | 4132 descriptor->Initialize( |
| 4126 Runtime::FunctionForId(Runtime::kRegExpConstructResult)->entry); | 4133 Runtime::FunctionForId(Runtime::kRegExpConstructResult)->entry); |
| 4134 descriptor->SetMissHandler(Runtime::kRegExpConstructResult); |
| 4127 } | 4135 } |
| 4128 | 4136 |
| 4129 | 4137 |
| 4130 void TransitionElementsKindStub::InitializeDescriptor( | 4138 void TransitionElementsKindStub::InitializeDescriptor( |
| 4131 CodeStubDescriptor* descriptor) { | 4139 CodeStubDescriptor* descriptor) { |
| 4132 descriptor->Initialize( | 4140 descriptor->Initialize( |
| 4133 Runtime::FunctionForId(Runtime::kTransitionElementsKind)->entry); | 4141 Runtime::FunctionForId(Runtime::kTransitionElementsKind)->entry); |
| 4134 } | 4142 } |
| 4135 | 4143 |
| 4136 | 4144 |
| 4137 void AllocateHeapNumberStub::InitializeDescriptor( | 4145 void AllocateHeapNumberStub::InitializeDescriptor( |
| 4138 CodeStubDescriptor* descriptor) { | 4146 CodeStubDescriptor* descriptor) { |
| 4139 descriptor->Initialize( | 4147 descriptor->Initialize( |
| 4140 Runtime::FunctionForId(Runtime::kAllocateHeapNumber)->entry); | 4148 Runtime::FunctionForId(Runtime::kAllocateHeapNumber)->entry); |
| 4141 } | 4149 } |
| 4142 | 4150 |
| 4143 | 4151 |
| 4144 #define SIMD128_INIT_DESC(TYPE, Type, type, lane_count, lane_type) \ | 4152 #define SIMD128_INIT_DESC(TYPE, Type, type, lane_count, lane_type) \ |
| 4145 void Allocate##Type##Stub::InitializeDescriptor( \ | 4153 void Allocate##Type##Stub::InitializeDescriptor( \ |
| 4146 CodeStubDescriptor* descriptor) { \ | 4154 CodeStubDescriptor* descriptor) { \ |
| 4147 descriptor->Initialize( \ | 4155 descriptor->Initialize( \ |
| 4148 Runtime::FunctionForId(Runtime::kCreate##Type)->entry); \ | 4156 Runtime::FunctionForId(Runtime::kCreate##Type)->entry); \ |
| 4149 } | 4157 } |
| 4150 SIMD128_TYPES(SIMD128_INIT_DESC) | 4158 SIMD128_TYPES(SIMD128_INIT_DESC) |
| 4151 #undef SIMD128_INIT_DESC | 4159 #undef SIMD128_INIT_DESC |
| 4152 | 4160 |
| 4153 void ToBooleanICStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { | 4161 void ToBooleanICStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { |
| 4154 descriptor->Initialize(FUNCTION_ADDR(Runtime_ToBooleanIC_Miss)); | 4162 descriptor->Initialize(FUNCTION_ADDR(Runtime_ToBooleanIC_Miss)); |
| 4155 descriptor->SetMissHandler(ExternalReference( | 4163 descriptor->SetMissHandler(Runtime::kToBooleanIC_Miss); |
| 4156 Runtime::FunctionForId(Runtime::kToBooleanIC_Miss), isolate())); | |
| 4157 } | 4164 } |
| 4158 | 4165 |
| 4159 | 4166 |
| 4160 void BinaryOpICStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { | 4167 void BinaryOpICStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { |
| 4161 descriptor->Initialize(FUNCTION_ADDR(Runtime_BinaryOpIC_Miss)); | 4168 descriptor->Initialize(FUNCTION_ADDR(Runtime_BinaryOpIC_Miss)); |
| 4162 descriptor->SetMissHandler(ExternalReference( | 4169 descriptor->SetMissHandler(Runtime::kBinaryOpIC_Miss); |
| 4163 Runtime::FunctionForId(Runtime::kBinaryOpIC_Miss), isolate())); | |
| 4164 } | 4170 } |
| 4165 | 4171 |
| 4166 | 4172 |
| 4167 void BinaryOpWithAllocationSiteStub::InitializeDescriptor( | 4173 void BinaryOpWithAllocationSiteStub::InitializeDescriptor( |
| 4168 CodeStubDescriptor* descriptor) { | 4174 CodeStubDescriptor* descriptor) { |
| 4169 descriptor->Initialize( | 4175 descriptor->Initialize( |
| 4170 FUNCTION_ADDR(Runtime_BinaryOpIC_MissWithAllocationSite)); | 4176 FUNCTION_ADDR(Runtime_BinaryOpIC_MissWithAllocationSite)); |
| 4171 } | 4177 } |
| 4172 | 4178 |
| 4173 | 4179 |
| 4174 void StringAddStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { | 4180 void StringAddStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { |
| 4175 descriptor->Initialize(Runtime::FunctionForId(Runtime::kStringAdd)->entry); | 4181 descriptor->Initialize(Runtime::FunctionForId(Runtime::kStringAdd)->entry); |
| 4182 descriptor->SetMissHandler(Runtime::kStringAdd); |
| 4176 } | 4183 } |
| 4177 | 4184 |
| 4178 | 4185 |
| 4179 void GrowArrayElementsStub::InitializeDescriptor( | 4186 void GrowArrayElementsStub::InitializeDescriptor( |
| 4180 CodeStubDescriptor* descriptor) { | 4187 CodeStubDescriptor* descriptor) { |
| 4181 descriptor->Initialize( | 4188 descriptor->Initialize( |
| 4182 Runtime::FunctionForId(Runtime::kGrowArrayElements)->entry); | 4189 Runtime::FunctionForId(Runtime::kGrowArrayElements)->entry); |
| 4183 } | 4190 } |
| 4184 | 4191 |
| 4185 | 4192 |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4568 | 4575 |
| 4569 | 4576 |
| 4570 void StoreElementStub::Generate(MacroAssembler* masm) { | 4577 void StoreElementStub::Generate(MacroAssembler* masm) { |
| 4571 DCHECK_EQ(DICTIONARY_ELEMENTS, elements_kind()); | 4578 DCHECK_EQ(DICTIONARY_ELEMENTS, elements_kind()); |
| 4572 ElementHandlerCompiler::GenerateStoreSlow(masm); | 4579 ElementHandlerCompiler::GenerateStoreSlow(masm); |
| 4573 } | 4580 } |
| 4574 | 4581 |
| 4575 | 4582 |
| 4576 // static | 4583 // static |
| 4577 void StoreFastElementStub::GenerateAheadOfTime(Isolate* isolate) { | 4584 void StoreFastElementStub::GenerateAheadOfTime(Isolate* isolate) { |
| 4585 if (FLAG_minimal) return; |
| 4578 StoreFastElementStub(isolate, false, FAST_HOLEY_ELEMENTS, STANDARD_STORE) | 4586 StoreFastElementStub(isolate, false, FAST_HOLEY_ELEMENTS, STANDARD_STORE) |
| 4579 .GetCode(); | 4587 .GetCode(); |
| 4580 StoreFastElementStub(isolate, false, FAST_HOLEY_ELEMENTS, | 4588 StoreFastElementStub(isolate, false, FAST_HOLEY_ELEMENTS, |
| 4581 STORE_AND_GROW_NO_TRANSITION).GetCode(); | 4589 STORE_AND_GROW_NO_TRANSITION).GetCode(); |
| 4582 for (int i = FIRST_FAST_ELEMENTS_KIND; i <= LAST_FAST_ELEMENTS_KIND; i++) { | 4590 for (int i = FIRST_FAST_ELEMENTS_KIND; i <= LAST_FAST_ELEMENTS_KIND; i++) { |
| 4583 ElementsKind kind = static_cast<ElementsKind>(i); | 4591 ElementsKind kind = static_cast<ElementsKind>(i); |
| 4584 StoreFastElementStub(isolate, true, kind, STANDARD_STORE).GetCode(); | 4592 StoreFastElementStub(isolate, true, kind, STANDARD_STORE).GetCode(); |
| 4585 StoreFastElementStub(isolate, true, kind, STORE_AND_GROW_NO_TRANSITION) | 4593 StoreFastElementStub(isolate, true, kind, STORE_AND_GROW_NO_TRANSITION) |
| 4586 .GetCode(); | 4594 .GetCode(); |
| 4587 } | 4595 } |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4924 if (type->Is(Type::UntaggedPointer())) { | 4932 if (type->Is(Type::UntaggedPointer())) { |
| 4925 return Representation::External(); | 4933 return Representation::External(); |
| 4926 } | 4934 } |
| 4927 | 4935 |
| 4928 DCHECK(!type->Is(Type::Untagged())); | 4936 DCHECK(!type->Is(Type::Untagged())); |
| 4929 return Representation::Tagged(); | 4937 return Representation::Tagged(); |
| 4930 } | 4938 } |
| 4931 | 4939 |
| 4932 } // namespace internal | 4940 } // namespace internal |
| 4933 } // namespace v8 | 4941 } // namespace v8 |
| OLD | NEW |