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

Side by Side Diff: src/code-stubs.cc

Issue 384403002: StubCallInterfaceDescriptor takes a context register. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: More refinements. Created 6 years, 5 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
OLDNEW
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 InterfaceDescriptor::InterfaceDescriptor()
20 : register_param_count_(-1) { }
21
22
19 CodeStubInterfaceDescriptor::CodeStubInterfaceDescriptor() 23 CodeStubInterfaceDescriptor::CodeStubInterfaceDescriptor()
20 : register_param_count_(-1), 24 : stack_parameter_count_(no_reg),
21 stack_parameter_count_(no_reg),
22 hint_stack_parameter_count_(-1), 25 hint_stack_parameter_count_(-1),
23 function_mode_(NOT_JS_FUNCTION_STUB_MODE), 26 function_mode_(NOT_JS_FUNCTION_STUB_MODE),
24 deoptimization_handler_(NULL), 27 deoptimization_handler_(NULL),
25 handler_arguments_mode_(DONT_PASS_ARGUMENTS), 28 handler_arguments_mode_(DONT_PASS_ARGUMENTS),
26 miss_handler_(), 29 miss_handler_(),
27 has_miss_handler_(false) { } 30 has_miss_handler_(false) { }
28 31
29 32
30 void CodeStubInterfaceDescriptor::Initialize( 33 void InterfaceDescriptor::Initialize(
31 int register_parameter_count, 34 int register_parameter_count,
32 Register* registers, 35 Register* registers,
33 Address deoptimization_handler, 36 Representation* register_param_representations) {
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; 37 register_param_count_ = register_parameter_count;
38
39 // An interface descriptor must have a context register.
40 ASSERT(register_parameter_count > 0 && registers[0].is(ContextRegister()));
41
42 // InterfaceDescriptor owns a copy of the registers array.
39 register_params_.Reset(NewArray<Register>(register_parameter_count)); 43 register_params_.Reset(NewArray<Register>(register_parameter_count));
40 for (int i = 0; i < register_parameter_count; i++) { 44 for (int i = 0; i < register_parameter_count; i++) {
41 register_params_[i] = registers[i]; 45 register_params_[i] = registers[i];
42 } 46 }
43 47
44 // If a representations array is specified, then the descriptor owns that as 48 // If a representations array is specified, then the descriptor owns that as
45 // well. 49 // well.
46 if (register_param_representations != NULL) { 50 if (register_param_representations != NULL) {
47 register_param_representations_.Reset( 51 register_param_representations_.Reset(
48 NewArray<Representation>(register_parameter_count)); 52 NewArray<Representation>(register_parameter_count));
49 for (int i = 0; i < register_parameter_count; i++) { 53 for (int i = 0; i < register_parameter_count; i++) {
54 // If there is a context register, the representation must be tagged.
55 ASSERT(i != 0 || register_param_representations[i].Equals(
56 Representation::Tagged()));
50 register_param_representations_[i] = register_param_representations[i]; 57 register_param_representations_[i] = register_param_representations[i];
51 } 58 }
52 } 59 }
60 }
61
62
63 void CodeStubInterfaceDescriptor::Initialize(
64 int register_parameter_count,
65 Register* registers,
66 Address deoptimization_handler,
67 Representation* register_param_representations,
68 int hint_stack_parameter_count,
69 StubFunctionMode function_mode) {
70 InterfaceDescriptor::Initialize(register_parameter_count, registers,
71 register_param_representations);
53 72
54 deoptimization_handler_ = deoptimization_handler; 73 deoptimization_handler_ = deoptimization_handler;
55 74
56 hint_stack_parameter_count_ = hint_stack_parameter_count; 75 hint_stack_parameter_count_ = hint_stack_parameter_count;
57 function_mode_ = function_mode; 76 function_mode_ = function_mode;
58 } 77 }
59 78
60 79
61 void CodeStubInterfaceDescriptor::Initialize( 80 void CodeStubInterfaceDescriptor::Initialize(
62 int register_parameter_count, 81 int register_parameter_count,
(...skipping 12 matching lines...) Expand all
75 stack_parameter_count_ = stack_parameter_count; 94 stack_parameter_count_ = stack_parameter_count;
76 handler_arguments_mode_ = handler_mode; 95 handler_arguments_mode_ = handler_mode;
77 } 96 }
78 97
79 98
80 void CallInterfaceDescriptor::Initialize( 99 void CallInterfaceDescriptor::Initialize(
81 int register_parameter_count, 100 int register_parameter_count,
82 Register* registers, 101 Register* registers,
83 Representation* param_representations, 102 Representation* param_representations,
84 PlatformCallInterfaceDescriptor* platform_descriptor) { 103 PlatformCallInterfaceDescriptor* platform_descriptor) {
85 // CallInterfaceDescriptor owns a copy of the registers array. 104 InterfaceDescriptor::Initialize(register_parameter_count, registers,
86 register_param_count_ = register_parameter_count; 105 param_representations);
87 register_params_.Reset(NewArray<Register>(register_parameter_count));
88 for (int i = 0; i < register_parameter_count; i++) {
89 register_params_[i] = registers[i];
90 }
91
92 // Also the register parameter representations.
93 param_representations_.Reset(
94 NewArray<Representation>(register_parameter_count));
95 for (int i = 0; i < register_parameter_count; i++) {
96 param_representations_[i] = param_representations[i];
97 }
98 106
99 platform_specific_descriptor_ = platform_descriptor; 107 platform_specific_descriptor_ = platform_descriptor;
100 } 108 }
101 109
102 110
103 bool CodeStub::FindCodeInCache(Code** code_out) { 111 bool CodeStub::FindCodeInCache(Code** code_out) {
104 UnseededNumberDictionary* stubs = isolate()->heap()->code_stubs(); 112 UnseededNumberDictionary* stubs = isolate()->heap()->code_stubs();
105 int index = stubs->FindEntry(GetKey()); 113 int index = stubs->FindEntry(GetKey());
106 if (index != UnseededNumberDictionary::kNotFound) { 114 if (index != UnseededNumberDictionary::kNotFound) {
107 *code_out = Code::cast(stubs->ValueAt(index)); 115 *code_out = Code::cast(stubs->ValueAt(index));
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 void JSEntryStub::FinishCode(Handle<Code> code) { 575 void JSEntryStub::FinishCode(Handle<Code> code) {
568 Handle<FixedArray> handler_table = 576 Handle<FixedArray> handler_table =
569 code->GetIsolate()->factory()->NewFixedArray(1, TENURED); 577 code->GetIsolate()->factory()->NewFixedArray(1, TENURED);
570 handler_table->set(0, Smi::FromInt(handler_offset_)); 578 handler_table->set(0, Smi::FromInt(handler_offset_));
571 code->set_handler_table(*handler_table); 579 code->set_handler_table(*handler_table);
572 } 580 }
573 581
574 582
575 void KeyedLoadFastElementStub::InitializeInterfaceDescriptor( 583 void KeyedLoadFastElementStub::InitializeInterfaceDescriptor(
576 CodeStubInterfaceDescriptor* descriptor) { 584 CodeStubInterfaceDescriptor* descriptor) {
577 Register registers[] = { LoadIC::ReceiverRegister(), 585 Register registers[] = { InterfaceDescriptor::ContextRegister(),
586 LoadIC::ReceiverRegister(),
578 LoadIC::NameRegister() }; 587 LoadIC::NameRegister() };
579 STATIC_ASSERT(LoadIC::kRegisterArgumentCount == 2); 588 STATIC_ASSERT(LoadIC::kRegisterArgumentCount == 2);
580 descriptor->Initialize(ARRAY_SIZE(registers), registers, 589 descriptor->Initialize(ARRAY_SIZE(registers), registers,
581 FUNCTION_ADDR(KeyedLoadIC_MissFromStubFailure)); 590 FUNCTION_ADDR(KeyedLoadIC_MissFromStubFailure));
582 } 591 }
583 592
584 593
585 void KeyedLoadDictionaryElementStub::InitializeInterfaceDescriptor( 594 void KeyedLoadDictionaryElementStub::InitializeInterfaceDescriptor(
586 CodeStubInterfaceDescriptor* descriptor) { 595 CodeStubInterfaceDescriptor* descriptor) {
587 Register registers[] = { LoadIC::ReceiverRegister(), 596 Register registers[] = { InterfaceDescriptor::ContextRegister(),
597 LoadIC::ReceiverRegister(),
588 LoadIC::NameRegister() }; 598 LoadIC::NameRegister() };
589 STATIC_ASSERT(LoadIC::kRegisterArgumentCount == 2); 599 STATIC_ASSERT(LoadIC::kRegisterArgumentCount == 2);
590 descriptor->Initialize(ARRAY_SIZE(registers), registers, 600 descriptor->Initialize(ARRAY_SIZE(registers), registers,
591 FUNCTION_ADDR(KeyedLoadIC_MissFromStubFailure)); 601 FUNCTION_ADDR(KeyedLoadIC_MissFromStubFailure));
592 } 602 }
593 603
594 604
595 void KeyedLoadGenericElementStub::InitializeInterfaceDescriptor( 605 void KeyedLoadGenericElementStub::InitializeInterfaceDescriptor(
596 CodeStubInterfaceDescriptor* descriptor) { 606 CodeStubInterfaceDescriptor* descriptor) {
597 Register registers[] = { LoadIC::ReceiverRegister(), 607 Register registers[] = { InterfaceDescriptor::ContextRegister(),
608 LoadIC::ReceiverRegister(),
598 LoadIC::NameRegister() }; 609 LoadIC::NameRegister() };
599 STATIC_ASSERT(LoadIC::kRegisterArgumentCount == 2); 610 STATIC_ASSERT(LoadIC::kRegisterArgumentCount == 2);
600 descriptor->Initialize( 611 descriptor->Initialize(
601 ARRAY_SIZE(registers), registers, 612 ARRAY_SIZE(registers), registers,
602 Runtime::FunctionForId(Runtime::kKeyedGetProperty)->entry); 613 Runtime::FunctionForId(Runtime::kKeyedGetProperty)->entry);
603 } 614 }
604 615
605 616
606 void LoadFieldStub::InitializeInterfaceDescriptor( 617 void LoadFieldStub::InitializeInterfaceDescriptor(
607 CodeStubInterfaceDescriptor* descriptor) { 618 CodeStubInterfaceDescriptor* descriptor) {
608 Register registers[] = { LoadIC::ReceiverRegister() }; 619 Register registers[] = { InterfaceDescriptor::ContextRegister(),
620 LoadIC::ReceiverRegister() };
609 descriptor->Initialize(ARRAY_SIZE(registers), registers); 621 descriptor->Initialize(ARRAY_SIZE(registers), registers);
610 } 622 }
611 623
612 624
613 void KeyedLoadFieldStub::InitializeInterfaceDescriptor( 625 void KeyedLoadFieldStub::InitializeInterfaceDescriptor(
614 CodeStubInterfaceDescriptor* descriptor) { 626 CodeStubInterfaceDescriptor* descriptor) {
615 Register registers[] = { LoadIC::ReceiverRegister() }; 627 Register registers[] = { InterfaceDescriptor::ContextRegister(),
628 LoadIC::ReceiverRegister() };
616 descriptor->Initialize(ARRAY_SIZE(registers), registers); 629 descriptor->Initialize(ARRAY_SIZE(registers), registers);
617 } 630 }
618 631
619 632
620 void StringLengthStub::InitializeInterfaceDescriptor( 633 void StringLengthStub::InitializeInterfaceDescriptor(
621 CodeStubInterfaceDescriptor* descriptor) { 634 CodeStubInterfaceDescriptor* descriptor) {
622 Register registers[] = { LoadIC::ReceiverRegister(), 635 Register registers[] = { InterfaceDescriptor::ContextRegister(),
636 LoadIC::ReceiverRegister(),
623 LoadIC::NameRegister() }; 637 LoadIC::NameRegister() };
624 descriptor->Initialize(ARRAY_SIZE(registers), registers); 638 descriptor->Initialize(ARRAY_SIZE(registers), registers);
625 } 639 }
626 640
627 641
628 void KeyedStringLengthStub::InitializeInterfaceDescriptor( 642 void KeyedStringLengthStub::InitializeInterfaceDescriptor(
629 CodeStubInterfaceDescriptor* descriptor) { 643 CodeStubInterfaceDescriptor* descriptor) {
630 Register registers[] = { LoadIC::ReceiverRegister(), 644 Register registers[] = { InterfaceDescriptor::ContextRegister(),
645 LoadIC::ReceiverRegister(),
631 LoadIC::NameRegister() }; 646 LoadIC::NameRegister() };
632 descriptor->Initialize(ARRAY_SIZE(registers), registers); 647 descriptor->Initialize(ARRAY_SIZE(registers), registers);
633 } 648 }
634 649
635 650
636 void KeyedStoreFastElementStub::InitializeInterfaceDescriptor( 651 void KeyedStoreFastElementStub::InitializeInterfaceDescriptor(
637 CodeStubInterfaceDescriptor* descriptor) { 652 CodeStubInterfaceDescriptor* descriptor) {
638 Register registers[] = { KeyedStoreIC::ReceiverRegister(), 653 Register registers[] = { InterfaceDescriptor::ContextRegister(),
654 KeyedStoreIC::ReceiverRegister(),
639 KeyedStoreIC::NameRegister(), 655 KeyedStoreIC::NameRegister(),
640 KeyedStoreIC::ValueRegister() }; 656 KeyedStoreIC::ValueRegister() };
641 descriptor->Initialize( 657 descriptor->Initialize(
642 ARRAY_SIZE(registers), registers, 658 ARRAY_SIZE(registers), registers,
643 FUNCTION_ADDR(KeyedStoreIC_MissFromStubFailure)); 659 FUNCTION_ADDR(KeyedStoreIC_MissFromStubFailure));
644 } 660 }
645 661
646 662
647 void StoreGlobalStub::InitializeInterfaceDescriptor( 663 void StoreGlobalStub::InitializeInterfaceDescriptor(
648 CodeStubInterfaceDescriptor* descriptor) { 664 CodeStubInterfaceDescriptor* descriptor) {
649 Register registers[] = { StoreIC::ReceiverRegister(), 665 Register registers[] = { InterfaceDescriptor::ContextRegister(),
666 StoreIC::ReceiverRegister(),
650 StoreIC::NameRegister(), 667 StoreIC::NameRegister(),
651 StoreIC::ValueRegister() }; 668 StoreIC::ValueRegister() };
652 descriptor->Initialize(ARRAY_SIZE(registers), registers, 669 descriptor->Initialize(ARRAY_SIZE(registers), registers,
653 FUNCTION_ADDR(StoreIC_MissFromStubFailure)); 670 FUNCTION_ADDR(StoreIC_MissFromStubFailure));
654 } 671 }
655 672
656 673
657 void KeyedLoadDictionaryElementPlatformStub::Generate( 674 void KeyedLoadDictionaryElementPlatformStub::Generate(
658 MacroAssembler* masm) { 675 MacroAssembler* masm) {
659 KeyedLoadStubCompiler::GenerateLoadDictionaryElement(masm); 676 KeyedLoadStubCompiler::GenerateLoadDictionaryElement(masm);
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 InstallDescriptor(isolate, &stub3); 978 InstallDescriptor(isolate, &stub3);
962 } 979 }
963 980
964 InternalArrayConstructorStub::InternalArrayConstructorStub( 981 InternalArrayConstructorStub::InternalArrayConstructorStub(
965 Isolate* isolate) : PlatformCodeStub(isolate) { 982 Isolate* isolate) : PlatformCodeStub(isolate) {
966 InternalArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate); 983 InternalArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate);
967 } 984 }
968 985
969 986
970 } } // namespace v8::internal 987 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698