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 #include "src/bootstrapper.h" | 7 #include "src/bootstrapper.h" |
8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
9 #include "src/cpu-profiler.h" | 9 #include "src/cpu-profiler.h" |
10 #include "src/factory.h" | 10 #include "src/factory.h" |
11 #include "src/gdb-jit.h" | 11 #include "src/gdb-jit.h" |
12 #include "src/macro-assembler.h" | 12 #include "src/macro-assembler.h" |
13 #include "src/stub-cache.h" | 13 #include "src/stub-cache.h" |
14 | 14 |
15 namespace v8 { | 15 namespace v8 { |
16 namespace internal { | 16 namespace internal { |
17 | 17 |
18 | 18 |
19 CodeStubInterfaceDescriptor::CodeStubInterfaceDescriptor() | 19 CodeStubInterfaceDescriptor::CodeStubInterfaceDescriptor() |
20 : register_param_count_(-1), | 20 : register_param_count_(-1), |
21 stack_parameter_count_(no_reg), | 21 stack_parameter_count_(no_reg), |
22 hint_stack_parameter_count_(-1), | 22 hint_stack_parameter_count_(-1), |
23 function_mode_(NOT_JS_FUNCTION_STUB_MODE), | 23 function_mode_(NOT_JS_FUNCTION_STUB_MODE), |
24 register_params_(NULL), | |
25 register_param_representations_(NULL), | |
26 deoptimization_handler_(NULL), | 24 deoptimization_handler_(NULL), |
27 handler_arguments_mode_(DONT_PASS_ARGUMENTS), | 25 handler_arguments_mode_(DONT_PASS_ARGUMENTS), |
28 miss_handler_(), | 26 miss_handler_(), |
29 has_miss_handler_(false) { } | 27 has_miss_handler_(false) { } |
30 | 28 |
31 | 29 |
| 30 void CodeStubInterfaceDescriptor::Initialize( |
| 31 int register_parameter_count, |
| 32 Register* registers, |
| 33 Address deoptimization_handler, |
| 34 Representation* register_param_representations, |
| 35 int hint_stack_parameter_count, |
| 36 StubFunctionMode function_mode) { |
| 37 // CodeStubInterfaceDescriptor owns a copy of the registers array. |
| 38 register_param_count_ = register_parameter_count; |
| 39 register_params_.Reset(NewArray<Register>(register_parameter_count)); |
| 40 for (int i = 0; i < register_parameter_count; i++) { |
| 41 register_params_[i] = registers[i]; |
| 42 } |
| 43 |
| 44 // If a representations array is specified, then the descriptor owns that as |
| 45 // well. |
| 46 if (register_param_representations != NULL) { |
| 47 register_param_representations_.Reset( |
| 48 NewArray<Representation>(register_parameter_count)); |
| 49 for (int i = 0; i < register_parameter_count; i++) { |
| 50 register_param_representations_[i] = register_param_representations[i]; |
| 51 } |
| 52 } |
| 53 |
| 54 deoptimization_handler_ = deoptimization_handler; |
| 55 |
| 56 hint_stack_parameter_count_ = hint_stack_parameter_count; |
| 57 function_mode_ = function_mode; |
| 58 } |
| 59 |
| 60 |
| 61 void CodeStubInterfaceDescriptor::Initialize( |
| 62 int register_parameter_count, |
| 63 Register* registers, |
| 64 Register stack_parameter_count, |
| 65 Address deoptimization_handler, |
| 66 Representation* register_param_representations, |
| 67 int hint_stack_parameter_count, |
| 68 StubFunctionMode function_mode, |
| 69 HandlerArgumentsMode handler_mode) { |
| 70 Initialize(register_parameter_count, registers, |
| 71 deoptimization_handler, |
| 72 register_param_representations, |
| 73 hint_stack_parameter_count, |
| 74 function_mode); |
| 75 stack_parameter_count_ = stack_parameter_count; |
| 76 handler_arguments_mode_ = handler_mode; |
| 77 } |
| 78 |
| 79 |
32 bool CodeStub::FindCodeInCache(Code** code_out) { | 80 bool CodeStub::FindCodeInCache(Code** code_out) { |
33 UnseededNumberDictionary* stubs = isolate()->heap()->code_stubs(); | 81 UnseededNumberDictionary* stubs = isolate()->heap()->code_stubs(); |
34 int index = stubs->FindEntry(GetKey()); | 82 int index = stubs->FindEntry(GetKey()); |
35 if (index != UnseededNumberDictionary::kNotFound) { | 83 if (index != UnseededNumberDictionary::kNotFound) { |
36 *code_out = Code::cast(stubs->ValueAt(index)); | 84 *code_out = Code::cast(stubs->ValueAt(index)); |
37 return true; | 85 return true; |
38 } | 86 } |
39 return false; | 87 return false; |
40 } | 88 } |
41 | 89 |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 | 553 |
506 | 554 |
507 void JSEntryStub::FinishCode(Handle<Code> code) { | 555 void JSEntryStub::FinishCode(Handle<Code> code) { |
508 Handle<FixedArray> handler_table = | 556 Handle<FixedArray> handler_table = |
509 code->GetIsolate()->factory()->NewFixedArray(1, TENURED); | 557 code->GetIsolate()->factory()->NewFixedArray(1, TENURED); |
510 handler_table->set(0, Smi::FromInt(handler_offset_)); | 558 handler_table->set(0, Smi::FromInt(handler_offset_)); |
511 code->set_handler_table(*handler_table); | 559 code->set_handler_table(*handler_table); |
512 } | 560 } |
513 | 561 |
514 | 562 |
| 563 void KeyedLoadFastElementStub::InitializeInterfaceDescriptor( |
| 564 CodeStubInterfaceDescriptor* descriptor) { |
| 565 Register registers[] = { KeyedLoadIC::ReceiverRegister(), |
| 566 KeyedLoadIC::NameRegister() }; |
| 567 STATIC_ASSERT(KeyedLoadIC::kRegisterArgumentCount == 2); |
| 568 descriptor->Initialize(ARRAY_SIZE(registers), registers, |
| 569 FUNCTION_ADDR(KeyedLoadIC_MissFromStubFailure)); |
| 570 } |
| 571 |
| 572 |
| 573 void KeyedLoadDictionaryElementStub::InitializeInterfaceDescriptor( |
| 574 CodeStubInterfaceDescriptor* descriptor) { |
| 575 Register registers[] = { KeyedLoadIC::ReceiverRegister(), |
| 576 KeyedLoadIC::NameRegister() }; |
| 577 STATIC_ASSERT(KeyedLoadIC::kRegisterArgumentCount == 2); |
| 578 descriptor->Initialize(ARRAY_SIZE(registers), registers, |
| 579 FUNCTION_ADDR(KeyedLoadIC_MissFromStubFailure)); |
| 580 } |
| 581 |
| 582 |
| 583 void KeyedLoadGenericElementStub::InitializeInterfaceDescriptor( |
| 584 CodeStubInterfaceDescriptor* descriptor) { |
| 585 Register registers[] = { KeyedLoadIC::ReceiverRegister(), |
| 586 KeyedLoadIC::NameRegister() }; |
| 587 STATIC_ASSERT(KeyedLoadIC::kRegisterArgumentCount == 2); |
| 588 descriptor->Initialize( |
| 589 ARRAY_SIZE(registers), registers, |
| 590 Runtime::FunctionForId(Runtime::kKeyedGetProperty)->entry); |
| 591 } |
| 592 |
| 593 |
515 void KeyedLoadDictionaryElementPlatformStub::Generate( | 594 void KeyedLoadDictionaryElementPlatformStub::Generate( |
516 MacroAssembler* masm) { | 595 MacroAssembler* masm) { |
517 KeyedLoadStubCompiler::GenerateLoadDictionaryElement(masm); | 596 KeyedLoadStubCompiler::GenerateLoadDictionaryElement(masm); |
518 } | 597 } |
519 | 598 |
520 | 599 |
521 void CreateAllocationSiteStub::GenerateAheadOfTime(Isolate* isolate) { | 600 void CreateAllocationSiteStub::GenerateAheadOfTime(Isolate* isolate) { |
522 CreateAllocationSiteStub stub(isolate); | 601 CreateAllocationSiteStub stub(isolate); |
523 stub.GetCode(); | 602 stub.GetCode(); |
524 } | 603 } |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 InstallDescriptor(isolate, &stub3); | 881 InstallDescriptor(isolate, &stub3); |
803 } | 882 } |
804 | 883 |
805 InternalArrayConstructorStub::InternalArrayConstructorStub( | 884 InternalArrayConstructorStub::InternalArrayConstructorStub( |
806 Isolate* isolate) : PlatformCodeStub(isolate) { | 885 Isolate* isolate) : PlatformCodeStub(isolate) { |
807 InternalArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate); | 886 InternalArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate); |
808 } | 887 } |
809 | 888 |
810 | 889 |
811 } } // namespace v8::internal | 890 } } // namespace v8::internal |
OLD | NEW |