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/api.h" | 6 #include "src/api.h" |
7 #include "src/assembler-inl.h" | 7 #include "src/assembler-inl.h" |
8 #include "src/builtins/builtins-descriptors.h" | 8 #include "src/builtins/builtins-descriptors.h" |
9 #include "src/callable.h" | 9 #include "src/callable.h" |
10 #include "src/isolate.h" | 10 #include "src/isolate.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN) | 126 IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN) |
127 #undef TFJ_CASE | 127 #undef TFJ_CASE |
128 default: | 128 default: |
129 UNREACHABLE(); | 129 UNREACHABLE(); |
130 return 0; | 130 return 0; |
131 } | 131 } |
132 } | 132 } |
133 | 133 |
134 // static | 134 // static |
135 Callable Builtins::CallableFor(Isolate* isolate, Name name) { | 135 Callable Builtins::CallableFor(Isolate* isolate, Name name) { |
| 136 Handle<Code> code( |
| 137 reinterpret_cast<Code**>(isolate->builtins()->builtin_address(name))); |
| 138 CallDescriptors::Key key; |
136 switch (name) { | 139 switch (name) { |
137 #define CASE(Name, ...) \ | 140 // This macro is deliberately crafted so as to emit very little code, |
138 case k##Name: { \ | 141 // in order to keep binary size of this function under control. |
139 Handle<Code> code = isolate->builtins()->Name(); \ | 142 #define CASE(Name, ...) \ |
140 auto descriptor = Builtin_##Name##_InterfaceDescriptor(isolate); \ | 143 case k##Name: { \ |
141 return Callable(code, descriptor); \ | 144 key = Builtin_##Name##_InterfaceDescriptor::key(); \ |
| 145 break; \ |
142 } | 146 } |
143 BUILTIN_LIST(IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN, CASE, CASE, | 147 BUILTIN_LIST(IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN, CASE, CASE, |
144 CASE, IGNORE_BUILTIN, IGNORE_BUILTIN) | 148 CASE, IGNORE_BUILTIN, IGNORE_BUILTIN) |
145 #undef CASE | 149 #undef CASE |
146 case kConsoleAssert: { | 150 case kConsoleAssert: { |
147 Handle<Code> code = isolate->builtins()->ConsoleAssert(); | |
148 return Callable(code, BuiltinDescriptor(isolate)); | 151 return Callable(code, BuiltinDescriptor(isolate)); |
149 } | 152 } |
150 default: | 153 default: |
151 UNREACHABLE(); | 154 UNREACHABLE(); |
152 return Callable(Handle<Code>::null(), VoidDescriptor(isolate)); | 155 return Callable(Handle<Code>::null(), VoidDescriptor(isolate)); |
153 } | 156 } |
| 157 CallInterfaceDescriptor descriptor(isolate, key); |
| 158 return Callable(code, descriptor); |
154 } | 159 } |
155 | 160 |
156 // static | 161 // static |
157 const char* Builtins::name(int index) { | 162 const char* Builtins::name(int index) { |
158 switch (index) { | 163 switch (index) { |
159 #define CASE(Name, ...) \ | 164 #define CASE(Name, ...) \ |
160 case k##Name: \ | 165 case k##Name: \ |
161 return #Name; | 166 return #Name; |
162 BUILTIN_LIST_ALL(CASE) | 167 BUILTIN_LIST_ALL(CASE) |
163 #undef CASE | 168 #undef CASE |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 // TODO(jochen): Remove this. | 260 // TODO(jochen): Remove this. |
256 if (responsible_context.is_null()) { | 261 if (responsible_context.is_null()) { |
257 return true; | 262 return true; |
258 } | 263 } |
259 if (*responsible_context == target->context()) return true; | 264 if (*responsible_context == target->context()) return true; |
260 return isolate->MayAccess(responsible_context, target_global_proxy); | 265 return isolate->MayAccess(responsible_context, target_global_proxy); |
261 } | 266 } |
262 | 267 |
263 } // namespace internal | 268 } // namespace internal |
264 } // namespace v8 | 269 } // namespace v8 |
OLD | NEW |