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/builtins/builtins.h" | 5 #include "src/builtins/builtins.h" |
6 #include "src/code-events.h" | 6 #include "src/code-events.h" |
7 #include "src/compiler/code-assembler.h" | 7 #include "src/compiler/code-assembler.h" |
8 #include "src/ic/ic-state.h" | 8 #include "src/ic/ic-state.h" |
9 #include "src/interface-descriptors.h" | 9 #include "src/interface-descriptors.h" |
10 #include "src/isolate.h" | 10 #include "src/isolate.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 generator(&state); | 91 generator(&state); |
92 Handle<Code> code = compiler::CodeAssembler::GenerateCode(&state); | 92 Handle<Code> code = compiler::CodeAssembler::GenerateCode(&state); |
93 PostBuildProfileAndTracing(isolate, *code, name); | 93 PostBuildProfileAndTracing(isolate, *code, name); |
94 return *code; | 94 return *code; |
95 } | 95 } |
96 | 96 |
97 // Builder for builtins implemented in TurboFan with CallStub linkage. | 97 // Builder for builtins implemented in TurboFan with CallStub linkage. |
98 Code* BuildWithCodeStubAssemblerCS(Isolate* isolate, | 98 Code* BuildWithCodeStubAssemblerCS(Isolate* isolate, |
99 CodeAssemblerGenerator generator, | 99 CodeAssemblerGenerator generator, |
100 CallDescriptors::Key interface_descriptor, | 100 CallDescriptors::Key interface_descriptor, |
101 Code::Flags flags, const char* name) { | 101 Code::Flags flags, const char* name, |
| 102 int result_size) { |
102 HandleScope scope(isolate); | 103 HandleScope scope(isolate); |
103 Zone zone(isolate->allocator(), ZONE_NAME); | 104 Zone zone(isolate->allocator(), ZONE_NAME); |
104 // The interface descriptor with given key must be initialized at this point | 105 // The interface descriptor with given key must be initialized at this point |
105 // and this construction just queries the details from the descriptors table. | 106 // and this construction just queries the details from the descriptors table. |
106 CallInterfaceDescriptor descriptor(isolate, interface_descriptor); | 107 CallInterfaceDescriptor descriptor(isolate, interface_descriptor); |
107 // Ensure descriptor is already initialized. | 108 // Ensure descriptor is already initialized. |
108 DCHECK_LE(0, descriptor.GetRegisterParameterCount()); | 109 DCHECK_LE(0, descriptor.GetRegisterParameterCount()); |
109 compiler::CodeAssemblerState state(isolate, &zone, descriptor, flags, name); | 110 compiler::CodeAssemblerState state(isolate, &zone, descriptor, flags, name, |
| 111 result_size); |
110 generator(&state); | 112 generator(&state); |
111 Handle<Code> code = compiler::CodeAssembler::GenerateCode(&state); | 113 Handle<Code> code = compiler::CodeAssembler::GenerateCode(&state); |
112 PostBuildProfileAndTracing(isolate, *code, name); | 114 PostBuildProfileAndTracing(isolate, *code, name); |
113 return *code; | 115 return *code; |
114 } | 116 } |
115 } // anonymous namespace | 117 } // anonymous namespace |
116 | 118 |
117 void Builtins::SetUp(Isolate* isolate, bool create_heap_objects) { | 119 void Builtins::SetUp(Isolate* isolate, bool create_heap_objects) { |
118 DCHECK(!initialized_); | 120 DCHECK(!initialized_); |
119 | 121 |
120 // Create a scope for the handles in the builtins. | 122 // Create a scope for the handles in the builtins. |
121 HandleScope scope(isolate); | 123 HandleScope scope(isolate); |
122 | 124 |
123 if (create_heap_objects) { | 125 if (create_heap_objects) { |
124 int index = 0; | 126 int index = 0; |
125 const Code::Flags kBuiltinFlags = Code::ComputeFlags(Code::BUILTIN); | 127 const Code::Flags kBuiltinFlags = Code::ComputeFlags(Code::BUILTIN); |
126 Code* code; | 128 Code* code; |
127 #define BUILD_CPP(Name) \ | 129 #define BUILD_CPP(Name) \ |
128 code = BuildAdaptor(isolate, FUNCTION_ADDR(Builtin_##Name), BUILTIN_EXIT, \ | 130 code = BuildAdaptor(isolate, FUNCTION_ADDR(Builtin_##Name), BUILTIN_EXIT, \ |
129 kBuiltinFlags, #Name); \ | 131 kBuiltinFlags, #Name); \ |
130 builtins_[index++] = code; | 132 builtins_[index++] = code; |
131 #define BUILD_API(Name) \ | 133 #define BUILD_API(Name) \ |
132 code = BuildAdaptor(isolate, FUNCTION_ADDR(Builtin_##Name), EXIT, \ | 134 code = BuildAdaptor(isolate, FUNCTION_ADDR(Builtin_##Name), EXIT, \ |
133 kBuiltinFlags, #Name); \ | 135 kBuiltinFlags, #Name); \ |
134 builtins_[index++] = code; | 136 builtins_[index++] = code; |
135 #define BUILD_TFJ(Name, Argc) \ | 137 #define BUILD_TFJ(Name, Argc) \ |
136 code = BuildWithCodeStubAssemblerJS(isolate, &Generate_##Name, Argc, \ | 138 code = BuildWithCodeStubAssemblerJS(isolate, &Generate_##Name, Argc, \ |
137 kBuiltinFlags, #Name); \ | 139 kBuiltinFlags, #Name); \ |
138 builtins_[index++] = code; | 140 builtins_[index++] = code; |
139 #define BUILD_TFS(Name, Kind, Extra, InterfaceDescriptor) \ | 141 #define BUILD_TFS(Name, Kind, Extra, InterfaceDescriptor, result_size) \ |
140 { InterfaceDescriptor##Descriptor descriptor(isolate); } \ | 142 { InterfaceDescriptor##Descriptor descriptor(isolate); } \ |
141 code = BuildWithCodeStubAssemblerCS( \ | 143 code = BuildWithCodeStubAssemblerCS( \ |
142 isolate, &Generate_##Name, CallDescriptors::InterfaceDescriptor, \ | 144 isolate, &Generate_##Name, CallDescriptors::InterfaceDescriptor, \ |
143 Code::ComputeFlags(Code::Kind, Extra), #Name); \ | 145 Code::ComputeFlags(Code::Kind, Extra), #Name, result_size); \ |
144 builtins_[index++] = code; | 146 builtins_[index++] = code; |
145 #define BUILD_ASM(Name) \ | 147 #define BUILD_ASM(Name) \ |
146 code = \ | 148 code = \ |
147 BuildWithMacroAssembler(isolate, Generate_##Name, kBuiltinFlags, #Name); \ | 149 BuildWithMacroAssembler(isolate, Generate_##Name, kBuiltinFlags, #Name); \ |
148 builtins_[index++] = code; | 150 builtins_[index++] = code; |
149 #define BUILD_ASH(Name, Kind, Extra) \ | 151 #define BUILD_ASH(Name, Kind, Extra) \ |
150 code = BuildWithMacroAssembler( \ | 152 code = BuildWithMacroAssembler( \ |
151 isolate, Generate_##Name, Code::ComputeFlags(Code::Kind, Extra), #Name); \ | 153 isolate, Generate_##Name, Code::ComputeFlags(Code::Kind, Extra), #Name); \ |
152 builtins_[index++] = code; | 154 builtins_[index++] = code; |
153 | 155 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 // TODO(jochen): Remove this. | 291 // TODO(jochen): Remove this. |
290 if (responsible_context.is_null()) { | 292 if (responsible_context.is_null()) { |
291 return true; | 293 return true; |
292 } | 294 } |
293 if (*responsible_context == target->context()) return true; | 295 if (*responsible_context == target->context()) return true; |
294 return isolate->MayAccess(responsible_context, target_global_proxy); | 296 return isolate->MayAccess(responsible_context, target_global_proxy); |
295 } | 297 } |
296 | 298 |
297 } // namespace internal | 299 } // namespace internal |
298 } // namespace v8 | 300 } // namespace v8 |
OLD | NEW |