OLD | NEW |
1 // Copyright 2017 the V8 project authors. All rights reserved. | 1 // Copyright 2017 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/setup-isolate.h" | 5 #include "src/setup-isolate.h" |
6 | 6 |
7 #include "src/builtins/builtins.h" | 7 #include "src/builtins/builtins.h" |
8 #include "src/code-events.h" | 8 #include "src/code-events.h" |
9 #include "src/compiler/code-assembler.h" | 9 #include "src/compiler/code-assembler.h" |
10 #include "src/interface-descriptors.h" | 10 #include "src/interface-descriptors.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 #endif | 34 #endif |
35 } | 35 } |
36 | 36 |
37 typedef void (*MacroAssemblerGenerator)(MacroAssembler*); | 37 typedef void (*MacroAssemblerGenerator)(MacroAssembler*); |
38 typedef void (*CodeAssemblerGenerator)(compiler::CodeAssemblerState*); | 38 typedef void (*CodeAssemblerGenerator)(compiler::CodeAssemblerState*); |
39 | 39 |
40 Code* BuildWithMacroAssembler(Isolate* isolate, | 40 Code* BuildWithMacroAssembler(Isolate* isolate, |
41 MacroAssemblerGenerator generator, | 41 MacroAssemblerGenerator generator, |
42 Code::Flags flags, const char* s_name) { | 42 Code::Flags flags, const char* s_name) { |
43 HandleScope scope(isolate); | 43 HandleScope scope(isolate); |
44 // Canonicalize handles, so that we can share constant pool entries pointing | |
45 // to code targets without dereferencing their handles. | |
46 CanonicalHandleScope canonical(isolate); | |
47 const size_t buffer_size = 32 * KB; | 44 const size_t buffer_size = 32 * KB; |
48 byte buffer[buffer_size]; // NOLINT(runtime/arrays) | 45 byte buffer[buffer_size]; // NOLINT(runtime/arrays) |
49 MacroAssembler masm(isolate, buffer, buffer_size, CodeObjectRequired::kYes); | 46 MacroAssembler masm(isolate, buffer, buffer_size, CodeObjectRequired::kYes); |
50 DCHECK(!masm.has_frame()); | 47 DCHECK(!masm.has_frame()); |
51 generator(&masm); | 48 generator(&masm); |
52 CodeDesc desc; | 49 CodeDesc desc; |
53 masm.GetCode(&desc); | 50 masm.GetCode(&desc); |
54 Handle<Code> code = | 51 Handle<Code> code = |
55 isolate->factory()->NewCode(desc, flags, masm.CodeObject()); | 52 isolate->factory()->NewCode(desc, flags, masm.CodeObject()); |
56 PostBuildProfileAndTracing(isolate, *code, s_name); | 53 PostBuildProfileAndTracing(isolate, *code, s_name); |
57 return *code; | 54 return *code; |
58 } | 55 } |
59 | 56 |
60 Code* BuildAdaptor(Isolate* isolate, Address builtin_address, | 57 Code* BuildAdaptor(Isolate* isolate, Address builtin_address, |
61 Builtins::ExitFrameType exit_frame_type, Code::Flags flags, | 58 Builtins::ExitFrameType exit_frame_type, Code::Flags flags, |
62 const char* name) { | 59 const char* name) { |
63 HandleScope scope(isolate); | 60 HandleScope scope(isolate); |
64 // Canonicalize handles, so that we can share constant pool entries pointing | |
65 // to code targets without dereferencing their handles. | |
66 CanonicalHandleScope canonical(isolate); | |
67 const size_t buffer_size = 32 * KB; | 61 const size_t buffer_size = 32 * KB; |
68 byte buffer[buffer_size]; // NOLINT(runtime/arrays) | 62 byte buffer[buffer_size]; // NOLINT(runtime/arrays) |
69 MacroAssembler masm(isolate, buffer, buffer_size, CodeObjectRequired::kYes); | 63 MacroAssembler masm(isolate, buffer, buffer_size, CodeObjectRequired::kYes); |
70 DCHECK(!masm.has_frame()); | 64 DCHECK(!masm.has_frame()); |
71 Builtins::Generate_Adaptor(&masm, builtin_address, exit_frame_type); | 65 Builtins::Generate_Adaptor(&masm, builtin_address, exit_frame_type); |
72 CodeDesc desc; | 66 CodeDesc desc; |
73 masm.GetCode(&desc); | 67 masm.GetCode(&desc); |
74 Handle<Code> code = | 68 Handle<Code> code = |
75 isolate->factory()->NewCode(desc, flags, masm.CodeObject()); | 69 isolate->factory()->NewCode(desc, flags, masm.CodeObject()); |
76 PostBuildProfileAndTracing(isolate, *code, name); | 70 PostBuildProfileAndTracing(isolate, *code, name); |
77 return *code; | 71 return *code; |
78 } | 72 } |
79 | 73 |
80 // Builder for builtins implemented in TurboFan with JS linkage. | 74 // Builder for builtins implemented in TurboFan with JS linkage. |
81 Code* BuildWithCodeStubAssemblerJS(Isolate* isolate, | 75 Code* BuildWithCodeStubAssemblerJS(Isolate* isolate, |
82 CodeAssemblerGenerator generator, int argc, | 76 CodeAssemblerGenerator generator, int argc, |
83 Code::Flags flags, const char* name) { | 77 Code::Flags flags, const char* name) { |
84 HandleScope scope(isolate); | 78 HandleScope scope(isolate); |
85 // Canonicalize handles, so that we can share constant pool entries pointing | |
86 // to code targets without dereferencing their handles. | |
87 CanonicalHandleScope canonical(isolate); | |
88 Zone zone(isolate->allocator(), ZONE_NAME); | 79 Zone zone(isolate->allocator(), ZONE_NAME); |
89 const int argc_with_recv = | 80 const int argc_with_recv = |
90 (argc == SharedFunctionInfo::kDontAdaptArgumentsSentinel) ? 0 : argc + 1; | 81 (argc == SharedFunctionInfo::kDontAdaptArgumentsSentinel) ? 0 : argc + 1; |
91 compiler::CodeAssemblerState state(isolate, &zone, argc_with_recv, flags, | 82 compiler::CodeAssemblerState state(isolate, &zone, argc_with_recv, flags, |
92 name); | 83 name); |
93 generator(&state); | 84 generator(&state); |
94 Handle<Code> code = compiler::CodeAssembler::GenerateCode(&state); | 85 Handle<Code> code = compiler::CodeAssembler::GenerateCode(&state); |
95 PostBuildProfileAndTracing(isolate, *code, name); | 86 PostBuildProfileAndTracing(isolate, *code, name); |
96 return *code; | 87 return *code; |
97 } | 88 } |
98 | 89 |
99 // Builder for builtins implemented in TurboFan with CallStub linkage. | 90 // Builder for builtins implemented in TurboFan with CallStub linkage. |
100 Code* BuildWithCodeStubAssemblerCS(Isolate* isolate, | 91 Code* BuildWithCodeStubAssemblerCS(Isolate* isolate, |
101 CodeAssemblerGenerator generator, | 92 CodeAssemblerGenerator generator, |
102 CallDescriptors::Key interface_descriptor, | 93 CallDescriptors::Key interface_descriptor, |
103 Code::Flags flags, const char* name, | 94 Code::Flags flags, const char* name, |
104 int result_size) { | 95 int result_size) { |
105 HandleScope scope(isolate); | 96 HandleScope scope(isolate); |
106 // Canonicalize handles, so that we can share constant pool entries pointing | |
107 // to code targets without dereferencing their handles. | |
108 CanonicalHandleScope canonical(isolate); | |
109 Zone zone(isolate->allocator(), ZONE_NAME); | 97 Zone zone(isolate->allocator(), ZONE_NAME); |
110 // The interface descriptor with given key must be initialized at this point | 98 // The interface descriptor with given key must be initialized at this point |
111 // and this construction just queries the details from the descriptors table. | 99 // and this construction just queries the details from the descriptors table. |
112 CallInterfaceDescriptor descriptor(isolate, interface_descriptor); | 100 CallInterfaceDescriptor descriptor(isolate, interface_descriptor); |
113 // Ensure descriptor is already initialized. | 101 // Ensure descriptor is already initialized. |
114 DCHECK_LE(0, descriptor.GetRegisterParameterCount()); | 102 DCHECK_LE(0, descriptor.GetRegisterParameterCount()); |
115 compiler::CodeAssemblerState state(isolate, &zone, descriptor, flags, name, | 103 compiler::CodeAssemblerState state(isolate, &zone, descriptor, flags, name, |
116 result_size); | 104 result_size); |
117 generator(&state); | 105 generator(&state); |
118 Handle<Code> code = compiler::CodeAssembler::GenerateCode(&state); | 106 Handle<Code> code = compiler::CodeAssembler::GenerateCode(&state); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 ->set_has_tagged_params(false); | 193 ->set_has_tagged_params(false); |
206 | 194 |
207 BUILTINS_WITH_UNTAGGED_PARAMS(SET_CODE_NON_TAGGED_PARAMS) | 195 BUILTINS_WITH_UNTAGGED_PARAMS(SET_CODE_NON_TAGGED_PARAMS) |
208 #undef SET_CODE_NON_TAGGED_PARAMS | 196 #undef SET_CODE_NON_TAGGED_PARAMS |
209 | 197 |
210 isolate->builtins()->MarkInitialized(); | 198 isolate->builtins()->MarkInitialized(); |
211 } | 199 } |
212 | 200 |
213 } // namespace internal | 201 } // namespace internal |
214 } // namespace v8 | 202 } // namespace v8 |
OLD | NEW |