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 // Also the register parameter representations array if one is specified. | |
Jakob Kummerow
2014/06/25 10:31:56
nit: this sentence no verb.
mvstanton
2014/06/25 12:29:00
Done.
| |
45 if (register_param_representations != NULL) { | |
46 register_param_representations_.Reset( | |
47 NewArray<Representation>(register_parameter_count)); | |
48 for (int i = 0; i < register_parameter_count; i++) { | |
49 register_param_representations_[i] = register_param_representations[i]; | |
50 } | |
51 } | |
52 | |
53 deoptimization_handler_ = deoptimization_handler; | |
54 | |
55 hint_stack_parameter_count_ = hint_stack_parameter_count; | |
56 function_mode_ = function_mode; | |
57 } | |
58 | |
59 | |
60 void CodeStubInterfaceDescriptor::Initialize( | |
61 int register_parameter_count, | |
62 Register* registers, | |
63 Register stack_parameter_count, | |
64 Address deoptimization_handler, | |
65 Representation* register_param_representations, | |
66 int hint_stack_parameter_count, | |
67 StubFunctionMode function_mode, | |
68 HandlerArgumentsMode handler_mode) { | |
69 Initialize(register_parameter_count, registers, | |
70 deoptimization_handler, | |
71 register_param_representations, | |
72 hint_stack_parameter_count, | |
73 function_mode); | |
74 stack_parameter_count_ = stack_parameter_count; | |
75 handler_arguments_mode_ = handler_mode; | |
76 } | |
77 | |
78 | |
32 bool CodeStub::FindCodeInCache(Code** code_out) { | 79 bool CodeStub::FindCodeInCache(Code** code_out) { |
33 UnseededNumberDictionary* stubs = isolate()->heap()->code_stubs(); | 80 UnseededNumberDictionary* stubs = isolate()->heap()->code_stubs(); |
34 int index = stubs->FindEntry(GetKey()); | 81 int index = stubs->FindEntry(GetKey()); |
35 if (index != UnseededNumberDictionary::kNotFound) { | 82 if (index != UnseededNumberDictionary::kNotFound) { |
36 *code_out = Code::cast(stubs->ValueAt(index)); | 83 *code_out = Code::cast(stubs->ValueAt(index)); |
37 return true; | 84 return true; |
38 } | 85 } |
39 return false; | 86 return false; |
40 } | 87 } |
41 | 88 |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
505 | 552 |
506 | 553 |
507 void JSEntryStub::FinishCode(Handle<Code> code) { | 554 void JSEntryStub::FinishCode(Handle<Code> code) { |
508 Handle<FixedArray> handler_table = | 555 Handle<FixedArray> handler_table = |
509 code->GetIsolate()->factory()->NewFixedArray(1, TENURED); | 556 code->GetIsolate()->factory()->NewFixedArray(1, TENURED); |
510 handler_table->set(0, Smi::FromInt(handler_offset_)); | 557 handler_table->set(0, Smi::FromInt(handler_offset_)); |
511 code->set_handler_table(*handler_table); | 558 code->set_handler_table(*handler_table); |
512 } | 559 } |
513 | 560 |
514 | 561 |
562 void KeyedLoadFastElementStub::InitializeInterfaceDescriptor( | |
563 CodeStubInterfaceDescriptor* descriptor) { | |
564 Register registers[] = { KeyedLoadIC::ReceiverRegister(), | |
565 KeyedLoadIC::NameRegister() }; | |
566 ASSERT_EQ(KeyedLoadIC::kRegisterArgumentCount, 2); | |
Jakob Kummerow
2014/06/25 10:31:56
nit: not sure I see the value of this ASSERT... bu
mvstanton
2014/06/25 12:29:00
Done (static assert). The reason for it is that th
| |
567 descriptor->Initialize(ARRAY_SIZE(registers), registers, | |
568 FUNCTION_ADDR(KeyedLoadIC_MissFromStubFailure)); | |
569 } | |
570 | |
571 | |
572 void KeyedLoadDictionaryElementStub::InitializeInterfaceDescriptor( | |
573 CodeStubInterfaceDescriptor* descriptor) { | |
574 Register registers[] = { KeyedLoadIC::ReceiverRegister(), | |
575 KeyedLoadIC::NameRegister() }; | |
576 ASSERT_EQ(KeyedLoadIC::kRegisterArgumentCount, 2); | |
577 descriptor->Initialize(ARRAY_SIZE(registers), registers, | |
578 FUNCTION_ADDR(KeyedLoadIC_MissFromStubFailure)); | |
579 } | |
580 | |
581 | |
582 void KeyedLoadGenericElementStub::InitializeInterfaceDescriptor( | |
583 CodeStubInterfaceDescriptor* descriptor) { | |
584 Register registers[] = { KeyedLoadIC::ReceiverRegister(), | |
585 KeyedLoadIC::NameRegister() }; | |
586 ASSERT_EQ(KeyedLoadIC::kRegisterArgumentCount, 2); | |
587 descriptor->Initialize( | |
588 ARRAY_SIZE(registers), registers, | |
589 Runtime::FunctionForId(Runtime::kKeyedGetProperty)->entry); | |
590 } | |
591 | |
592 | |
515 void KeyedLoadDictionaryElementPlatformStub::Generate( | 593 void KeyedLoadDictionaryElementPlatformStub::Generate( |
516 MacroAssembler* masm) { | 594 MacroAssembler* masm) { |
517 KeyedLoadStubCompiler::GenerateLoadDictionaryElement(masm); | 595 KeyedLoadStubCompiler::GenerateLoadDictionaryElement(masm); |
518 } | 596 } |
519 | 597 |
520 | 598 |
521 void CreateAllocationSiteStub::GenerateAheadOfTime(Isolate* isolate) { | 599 void CreateAllocationSiteStub::GenerateAheadOfTime(Isolate* isolate) { |
522 CreateAllocationSiteStub stub(isolate); | 600 CreateAllocationSiteStub stub(isolate); |
523 stub.GetCode(); | 601 stub.GetCode(); |
524 } | 602 } |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
802 InstallDescriptor(isolate, &stub3); | 880 InstallDescriptor(isolate, &stub3); |
803 } | 881 } |
804 | 882 |
805 InternalArrayConstructorStub::InternalArrayConstructorStub( | 883 InternalArrayConstructorStub::InternalArrayConstructorStub( |
806 Isolate* isolate) : PlatformCodeStub(isolate) { | 884 Isolate* isolate) : PlatformCodeStub(isolate) { |
807 InternalArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate); | 885 InternalArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate); |
808 } | 886 } |
809 | 887 |
810 | 888 |
811 } } // namespace v8::internal | 889 } } // namespace v8::internal |
OLD | NEW |