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

Side by Side Diff: src/builtins/builtins.cc

Issue 2777203007: [builtins] Introduce new TFC macro and auto-generate TFS descriptors (Closed)
Patch Set: Format Created 3 years, 8 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
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/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/code-events.h" 10 #include "src/code-events.h"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 kBuiltinFlags, #Name); \ 135 kBuiltinFlags, #Name); \
136 builtins_[index++] = code; 136 builtins_[index++] = code;
137 #define BUILD_API(Name) \ 137 #define BUILD_API(Name) \
138 code = BuildAdaptor(isolate, FUNCTION_ADDR(Builtin_##Name), EXIT, \ 138 code = BuildAdaptor(isolate, FUNCTION_ADDR(Builtin_##Name), EXIT, \
139 kBuiltinFlags, #Name); \ 139 kBuiltinFlags, #Name); \
140 builtins_[index++] = code; 140 builtins_[index++] = code;
141 #define BUILD_TFJ(Name, Argc, ...) \ 141 #define BUILD_TFJ(Name, Argc, ...) \
142 code = BuildWithCodeStubAssemblerJS(isolate, &Generate_##Name, Argc, \ 142 code = BuildWithCodeStubAssemblerJS(isolate, &Generate_##Name, Argc, \
143 kBuiltinFlags, #Name); \ 143 kBuiltinFlags, #Name); \
144 builtins_[index++] = code; 144 builtins_[index++] = code;
145 #define BUILD_TFS(Name, InterfaceDescriptor, result_size) \ 145 #define BUILD_TFC(Name, InterfaceDescriptor, result_size) \
146 { InterfaceDescriptor##Descriptor descriptor(isolate); } \ 146 { InterfaceDescriptor##Descriptor descriptor(isolate); } \
147 code = BuildWithCodeStubAssemblerCS(isolate, &Generate_##Name, \ 147 code = BuildWithCodeStubAssemblerCS(isolate, &Generate_##Name, \
148 CallDescriptors::InterfaceDescriptor, \ 148 CallDescriptors::InterfaceDescriptor, \
149 kBuiltinFlags, #Name, result_size); \ 149 kBuiltinFlags, #Name, result_size); \
150 builtins_[index++] = code; 150 builtins_[index++] = code;
151 #define BUILD_TFS(Name, ...) \
152 /* Return size for generic TF builtins (stub linkage) is always 1. */ \
153 code = BuildWithCodeStubAssemblerCS(isolate, &Generate_##Name, \
154 CallDescriptors::Name, kBuiltinFlags, \
155 #Name, 1); \
156 builtins_[index++] = code;
151 #define BUILD_TFH(Name, Kind, Extra, InterfaceDescriptor) \ 157 #define BUILD_TFH(Name, Kind, Extra, InterfaceDescriptor) \
152 { InterfaceDescriptor##Descriptor descriptor(isolate); } \ 158 { InterfaceDescriptor##Descriptor descriptor(isolate); } \
153 /* Return size for IC builtins/handlers is always 1. */ \ 159 /* Return size for IC builtins/handlers is always 1. */ \
154 code = BuildWithCodeStubAssemblerCS( \ 160 code = BuildWithCodeStubAssemblerCS( \
155 isolate, &Generate_##Name, CallDescriptors::InterfaceDescriptor, \ 161 isolate, &Generate_##Name, CallDescriptors::InterfaceDescriptor, \
156 Code::ComputeFlags(Code::Kind, Extra), #Name, 1); \ 162 Code::ComputeFlags(Code::Kind, Extra), #Name, 1); \
157 builtins_[index++] = code; 163 builtins_[index++] = code;
158 #define BUILD_ASM(Name) \ 164 #define BUILD_ASM(Name) \
159 code = \ 165 code = \
160 BuildWithMacroAssembler(isolate, Generate_##Name, kBuiltinFlags, #Name); \ 166 BuildWithMacroAssembler(isolate, Generate_##Name, kBuiltinFlags, #Name); \
161 builtins_[index++] = code; 167 builtins_[index++] = code;
162 168
163 BUILTIN_LIST(BUILD_CPP, BUILD_API, BUILD_TFJ, BUILD_TFS, BUILD_TFH, 169 BUILTIN_LIST(BUILD_CPP, BUILD_API, BUILD_TFJ, BUILD_TFC, BUILD_TFS,
164 BUILD_ASM, BUILD_ASM); 170 BUILD_TFH, BUILD_ASM, BUILD_ASM);
165 171
166 #undef BUILD_CPP 172 #undef BUILD_CPP
167 #undef BUILD_API 173 #undef BUILD_API
168 #undef BUILD_TFJ 174 #undef BUILD_TFJ
175 #undef BUILD_TFC
169 #undef BUILD_TFS 176 #undef BUILD_TFS
170 #undef BUILD_TFH 177 #undef BUILD_TFH
171 #undef BUILD_ASM 178 #undef BUILD_ASM
172 CHECK_EQ(builtin_count, index); 179 CHECK_EQ(builtin_count, index);
173 for (int i = 0; i < builtin_count; i++) { 180 for (int i = 0; i < builtin_count; i++) {
174 Code::cast(builtins_[i])->set_builtin_index(i); 181 Code::cast(builtins_[i])->set_builtin_index(i);
175 } 182 }
176 183
177 #define SET_PROMISE_REJECTION_PREDICTION(Name) \ 184 #define SET_PROMISE_REJECTION_PREDICTION(Name) \
178 Code::cast(builtins_[k##Name])->set_is_promise_rejection(true); 185 Code::cast(builtins_[k##Name])->set_is_promise_rejection(true);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 // static 294 // static
288 Callable Builtins::CallableFor(Isolate* isolate, Name name) { 295 Callable Builtins::CallableFor(Isolate* isolate, Name name) {
289 switch (name) { 296 switch (name) {
290 #define CASE(Name, ...) \ 297 #define CASE(Name, ...) \
291 case k##Name: { \ 298 case k##Name: { \
292 Handle<Code> code(Code::cast(isolate->builtins()->builtins_[name])); \ 299 Handle<Code> code(Code::cast(isolate->builtins()->builtins_[name])); \
293 auto descriptor = Builtin_##Name##_InterfaceDescriptor(isolate); \ 300 auto descriptor = Builtin_##Name##_InterfaceDescriptor(isolate); \
294 return Callable(code, descriptor); \ 301 return Callable(code, descriptor); \
295 } 302 }
296 BUILTIN_LIST(IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN, CASE, CASE, 303 BUILTIN_LIST(IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN, CASE, CASE,
297 IGNORE_BUILTIN, IGNORE_BUILTIN) 304 CASE, IGNORE_BUILTIN, IGNORE_BUILTIN)
298 #undef CASE 305 #undef CASE
299 default: 306 default:
300 UNREACHABLE(); 307 UNREACHABLE();
301 return Callable(Handle<Code>::null(), VoidDescriptor(isolate)); 308 return Callable(Handle<Code>::null(), VoidDescriptor(isolate));
302 } 309 }
303 } 310 }
304 311
305 // static 312 // static
306 const char* Builtins::name(int index) { 313 const char* Builtins::name(int index) {
307 switch (index) { 314 switch (index) {
(...skipping 26 matching lines...) Expand all
334 341
335 // static 342 // static
336 bool Builtins::IsCpp(int index) { 343 bool Builtins::IsCpp(int index) {
337 DCHECK(0 <= index && index < builtin_count); 344 DCHECK(0 <= index && index < builtin_count);
338 switch (index) { 345 switch (index) {
339 #define CASE(Name, ...) \ 346 #define CASE(Name, ...) \
340 case k##Name: \ 347 case k##Name: \
341 return true; 348 return true;
342 #define BUILTIN_LIST_CPP(V) \ 349 #define BUILTIN_LIST_CPP(V) \
343 BUILTIN_LIST(V, IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN, \ 350 BUILTIN_LIST(V, IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN, \
344 IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN) 351 IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN)
345 BUILTIN_LIST_CPP(CASE) 352 BUILTIN_LIST_CPP(CASE)
346 #undef BUILTIN_LIST_CPP 353 #undef BUILTIN_LIST_CPP
347 #undef CASE 354 #undef CASE
348 default: 355 default:
349 return false; 356 return false;
350 } 357 }
351 UNREACHABLE(); 358 UNREACHABLE();
352 } 359 }
353 360
354 // static 361 // static
355 bool Builtins::IsApi(int index) { 362 bool Builtins::IsApi(int index) {
356 DCHECK(0 <= index && index < builtin_count); 363 DCHECK(0 <= index && index < builtin_count);
357 switch (index) { 364 switch (index) {
358 #define CASE(Name, ...) \ 365 #define CASE(Name, ...) \
359 case k##Name: \ 366 case k##Name: \
360 return true; 367 return true;
361 #define BUILTIN_LIST_API(V) \ 368 #define BUILTIN_LIST_API(V) \
362 BUILTIN_LIST(IGNORE_BUILTIN, V, IGNORE_BUILTIN, IGNORE_BUILTIN, \ 369 BUILTIN_LIST(IGNORE_BUILTIN, V, IGNORE_BUILTIN, IGNORE_BUILTIN, \
363 IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN) 370 IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN)
364 BUILTIN_LIST_API(CASE); 371 BUILTIN_LIST_API(CASE);
365 #undef BUILTIN_LIST_API 372 #undef BUILTIN_LIST_API
366 #undef CASE 373 #undef CASE
367 default: 374 default:
368 return false; 375 return false;
369 } 376 }
370 UNREACHABLE(); 377 UNREACHABLE();
371 } 378 }
372 379
373 // static 380 // static
(...skipping 30 matching lines...) Expand all
404 // TODO(jochen): Remove this. 411 // TODO(jochen): Remove this.
405 if (responsible_context.is_null()) { 412 if (responsible_context.is_null()) {
406 return true; 413 return true;
407 } 414 }
408 if (*responsible_context == target->context()) return true; 415 if (*responsible_context == target->context()) return true;
409 return isolate->MayAccess(responsible_context, target_global_proxy); 416 return isolate->MayAccess(responsible_context, target_global_proxy);
410 } 417 }
411 418
412 } // namespace internal 419 } // namespace internal
413 } // namespace v8 420 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698