OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 #ifndef V8_BUILTINS_H_ | 5 #ifndef V8_BUILTINS_H_ |
6 #define V8_BUILTINS_H_ | 6 #define V8_BUILTINS_H_ |
7 | 7 |
8 #include "src/base/flags.h" | 8 #include "src/base/flags.h" |
9 #include "src/handles.h" | 9 #include "src/handles.h" |
10 | 10 |
(...skipping 20 matching lines...) Expand all Loading... | |
31 V(NotExecuted) \ | 31 V(NotExecuted) \ |
32 V(ExecutedOnce) \ | 32 V(ExecutedOnce) \ |
33 V(NoAge) \ | 33 V(NoAge) \ |
34 CODE_AGE_LIST_WITH_ARG(CODE_AGE_LIST_IGNORE_ARG, V) | 34 CODE_AGE_LIST_WITH_ARG(CODE_AGE_LIST_IGNORE_ARG, V) |
35 | 35 |
36 #define DECLARE_CODE_AGE_BUILTIN(C, V) \ | 36 #define DECLARE_CODE_AGE_BUILTIN(C, V) \ |
37 V(Make##C##CodeYoungAgainOddMarking, BUILTIN, kNoExtraICState) \ | 37 V(Make##C##CodeYoungAgainOddMarking, BUILTIN, kNoExtraICState) \ |
38 V(Make##C##CodeYoungAgainEvenMarking, BUILTIN, kNoExtraICState) | 38 V(Make##C##CodeYoungAgainEvenMarking, BUILTIN, kNoExtraICState) |
39 | 39 |
40 // Define list of builtins implemented in C++. | 40 // Define list of builtins implemented in C++. |
41 #define BUILTIN_LIST_C(V) \ | 41 #define BUILTIN_LIST_C(V) \ |
42 V(Illegal) \ | 42 V(Illegal, true) \ |
Yang
2016/06/27 08:30:02
Might be nicer to have an enum instead of a boolea
| |
43 \ | 43 \ |
44 V(EmptyFunction) \ | 44 V(EmptyFunction, true) \ |
45 \ | 45 \ |
46 V(ArrayConcat) \ | 46 V(ArrayConcat, true) \ |
47 V(ArrayPop) \ | 47 V(ArrayPop, true) \ |
48 V(ArrayPush) \ | 48 V(ArrayPush, true) \ |
49 V(ArrayShift) \ | 49 V(ArrayShift, true) \ |
50 V(ArraySlice) \ | 50 V(ArraySlice, true) \ |
51 V(ArraySplice) \ | 51 V(ArraySplice, true) \ |
52 V(ArrayUnshift) \ | 52 V(ArrayUnshift, true) \ |
53 \ | 53 \ |
54 V(ArrayBufferConstructor) \ | 54 V(ArrayBufferConstructor, true) \ |
55 V(ArrayBufferConstructor_ConstructStub) \ | 55 V(ArrayBufferConstructor_ConstructStub, true) \ |
56 V(ArrayBufferIsView) \ | 56 V(ArrayBufferIsView, true) \ |
57 \ | 57 \ |
58 V(BooleanConstructor) \ | 58 V(BooleanConstructor, true) \ |
59 V(BooleanConstructor_ConstructStub) \ | 59 V(BooleanConstructor_ConstructStub, true) \ |
60 V(BooleanPrototypeToString) \ | 60 V(BooleanPrototypeToString, true) \ |
61 V(BooleanPrototypeValueOf) \ | 61 V(BooleanPrototypeValueOf, true) \ |
62 \ | 62 \ |
63 V(DataViewConstructor) \ | 63 V(DataViewConstructor, true) \ |
64 V(DataViewConstructor_ConstructStub) \ | 64 V(DataViewConstructor_ConstructStub, true) \ |
65 V(DataViewPrototypeGetBuffer) \ | 65 V(DataViewPrototypeGetBuffer, true) \ |
66 V(DataViewPrototypeGetByteLength) \ | 66 V(DataViewPrototypeGetByteLength, true) \ |
67 V(DataViewPrototypeGetByteOffset) \ | 67 V(DataViewPrototypeGetByteOffset, true) \ |
68 \ | 68 \ |
69 V(DateConstructor) \ | 69 V(DateConstructor, true) \ |
70 V(DateConstructor_ConstructStub) \ | 70 V(DateConstructor_ConstructStub, true) \ |
71 V(DateNow) \ | 71 V(DateNow, true) \ |
72 V(DateParse) \ | 72 V(DateParse, true) \ |
73 V(DateUTC) \ | 73 V(DateUTC, true) \ |
74 V(DatePrototypeSetDate) \ | 74 V(DatePrototypeSetDate, true) \ |
75 V(DatePrototypeSetFullYear) \ | 75 V(DatePrototypeSetFullYear, true) \ |
76 V(DatePrototypeSetHours) \ | 76 V(DatePrototypeSetHours, true) \ |
77 V(DatePrototypeSetMilliseconds) \ | 77 V(DatePrototypeSetMilliseconds, true) \ |
78 V(DatePrototypeSetMinutes) \ | 78 V(DatePrototypeSetMinutes, true) \ |
79 V(DatePrototypeSetMonth) \ | 79 V(DatePrototypeSetMonth, true) \ |
80 V(DatePrototypeSetSeconds) \ | 80 V(DatePrototypeSetSeconds, true) \ |
81 V(DatePrototypeSetTime) \ | 81 V(DatePrototypeSetTime, true) \ |
82 V(DatePrototypeSetUTCDate) \ | 82 V(DatePrototypeSetUTCDate, true) \ |
83 V(DatePrototypeSetUTCFullYear) \ | 83 V(DatePrototypeSetUTCFullYear, true) \ |
84 V(DatePrototypeSetUTCHours) \ | 84 V(DatePrototypeSetUTCHours, true) \ |
85 V(DatePrototypeSetUTCMilliseconds) \ | 85 V(DatePrototypeSetUTCMilliseconds, true) \ |
86 V(DatePrototypeSetUTCMinutes) \ | 86 V(DatePrototypeSetUTCMinutes, true) \ |
87 V(DatePrototypeSetUTCMonth) \ | 87 V(DatePrototypeSetUTCMonth, true) \ |
88 V(DatePrototypeSetUTCSeconds) \ | 88 V(DatePrototypeSetUTCSeconds, true) \ |
89 V(DatePrototypeToDateString) \ | 89 V(DatePrototypeToDateString, true) \ |
90 V(DatePrototypeToISOString) \ | 90 V(DatePrototypeToISOString, true) \ |
91 V(DatePrototypeToPrimitive) \ | 91 V(DatePrototypeToPrimitive, true) \ |
92 V(DatePrototypeToUTCString) \ | 92 V(DatePrototypeToUTCString, true) \ |
93 V(DatePrototypeToString) \ | 93 V(DatePrototypeToString, true) \ |
94 V(DatePrototypeToTimeString) \ | 94 V(DatePrototypeToTimeString, true) \ |
95 V(DatePrototypeValueOf) \ | 95 V(DatePrototypeValueOf, true) \ |
96 V(DatePrototypeGetYear) \ | 96 V(DatePrototypeGetYear, true) \ |
97 V(DatePrototypeSetYear) \ | 97 V(DatePrototypeSetYear, true) \ |
98 V(DatePrototypeToJson) \ | 98 V(DatePrototypeToJson, true) \ |
99 \ | 99 \ |
100 V(FunctionConstructor) \ | 100 V(FunctionConstructor, true) \ |
101 V(FunctionPrototypeBind) \ | 101 V(FunctionPrototypeBind, true) \ |
102 V(FunctionPrototypeToString) \ | 102 V(FunctionPrototypeToString, true) \ |
103 \ | 103 \ |
104 V(GeneratorFunctionConstructor) \ | 104 V(GeneratorFunctionConstructor, true) \ |
105 V(AsyncFunctionConstructor) \ | 105 V(AsyncFunctionConstructor, true) \ |
106 \ | 106 \ |
107 V(GlobalDecodeURI) \ | 107 V(GlobalDecodeURI, true) \ |
108 V(GlobalDecodeURIComponent) \ | 108 V(GlobalDecodeURIComponent, true) \ |
109 V(GlobalEncodeURI) \ | 109 V(GlobalEncodeURI, true) \ |
110 V(GlobalEncodeURIComponent) \ | 110 V(GlobalEncodeURIComponent, true) \ |
111 V(GlobalEscape) \ | 111 V(GlobalEscape, true) \ |
112 V(GlobalUnescape) \ | 112 V(GlobalUnescape, true) \ |
113 \ | 113 \ |
114 V(GlobalEval) \ | 114 V(GlobalEval, true) \ |
115 \ | 115 \ |
116 V(JsonParse) \ | 116 V(JsonParse, true) \ |
117 V(JsonStringify) \ | 117 V(JsonStringify, true) \ |
118 \ | 118 \ |
119 V(MathAcos) \ | 119 V(MathAcos, true) \ |
120 V(MathAsin) \ | 120 V(MathAsin, true) \ |
121 V(MathFround) \ | 121 V(MathFround, true) \ |
122 V(MathImul) \ | 122 V(MathImul, true) \ |
123 \ | 123 \ |
124 V(ObjectAssign) \ | 124 V(ObjectAssign, true) \ |
125 V(ObjectCreate) \ | 125 V(ObjectCreate, true) \ |
126 V(ObjectDefineGetter) \ | 126 V(ObjectDefineGetter, true) \ |
127 V(ObjectDefineProperties) \ | 127 V(ObjectDefineProperties, true) \ |
128 V(ObjectDefineProperty) \ | 128 V(ObjectDefineProperty, true) \ |
129 V(ObjectDefineSetter) \ | 129 V(ObjectDefineSetter, true) \ |
130 V(ObjectEntries) \ | 130 V(ObjectEntries, true) \ |
131 V(ObjectFreeze) \ | 131 V(ObjectFreeze, true) \ |
132 V(ObjectGetOwnPropertyDescriptor) \ | 132 V(ObjectGetOwnPropertyDescriptor, true) \ |
133 V(ObjectGetOwnPropertyDescriptors) \ | 133 V(ObjectGetOwnPropertyDescriptors, true) \ |
134 V(ObjectGetOwnPropertyNames) \ | 134 V(ObjectGetOwnPropertyNames, true) \ |
135 V(ObjectGetOwnPropertySymbols) \ | 135 V(ObjectGetOwnPropertySymbols, true) \ |
136 V(ObjectGetPrototypeOf) \ | 136 V(ObjectGetPrototypeOf, true) \ |
137 V(ObjectIs) \ | 137 V(ObjectIs, true) \ |
138 V(ObjectIsExtensible) \ | 138 V(ObjectIsExtensible, true) \ |
139 V(ObjectIsFrozen) \ | 139 V(ObjectIsFrozen, true) \ |
140 V(ObjectIsSealed) \ | 140 V(ObjectIsSealed, true) \ |
141 V(ObjectKeys) \ | 141 V(ObjectKeys, true) \ |
142 V(ObjectLookupGetter) \ | 142 V(ObjectLookupGetter, true) \ |
143 V(ObjectLookupSetter) \ | 143 V(ObjectLookupSetter, true) \ |
144 V(ObjectPreventExtensions) \ | 144 V(ObjectPreventExtensions, true) \ |
145 V(ObjectProtoToString) \ | 145 V(ObjectProtoToString, true) \ |
146 V(ObjectSeal) \ | 146 V(ObjectSeal, true) \ |
147 V(ObjectValues) \ | 147 V(ObjectValues, true) \ |
148 \ | 148 \ |
149 V(ProxyConstructor) \ | 149 V(ProxyConstructor, true) \ |
150 V(ProxyConstructor_ConstructStub) \ | 150 V(ProxyConstructor_ConstructStub, true) \ |
151 \ | 151 \ |
152 V(ReflectDefineProperty) \ | 152 V(ReflectDefineProperty, true) \ |
153 V(ReflectDeleteProperty) \ | 153 V(ReflectDeleteProperty, true) \ |
154 V(ReflectGet) \ | 154 V(ReflectGet, true) \ |
155 V(ReflectGetOwnPropertyDescriptor) \ | 155 V(ReflectGetOwnPropertyDescriptor, true) \ |
156 V(ReflectGetPrototypeOf) \ | 156 V(ReflectGetPrototypeOf, true) \ |
157 V(ReflectHas) \ | 157 V(ReflectHas, true) \ |
158 V(ReflectIsExtensible) \ | 158 V(ReflectIsExtensible, true) \ |
159 V(ReflectOwnKeys) \ | 159 V(ReflectOwnKeys, true) \ |
160 V(ReflectPreventExtensions) \ | 160 V(ReflectPreventExtensions, true) \ |
161 V(ReflectSet) \ | 161 V(ReflectSet, true) \ |
162 V(ReflectSetPrototypeOf) \ | 162 V(ReflectSetPrototypeOf, true) \ |
163 \ | 163 \ |
164 V(StringPrototypeTrim) \ | 164 V(StringPrototypeTrim, true) \ |
165 V(StringPrototypeTrimLeft) \ | 165 V(StringPrototypeTrimLeft, true) \ |
166 V(StringPrototypeTrimRight) \ | 166 V(StringPrototypeTrimRight, true) \ |
167 \ | 167 \ |
168 V(SymbolConstructor) \ | 168 V(SymbolConstructor, true) \ |
169 V(SymbolConstructor_ConstructStub) \ | 169 V(SymbolConstructor_ConstructStub, true) \ |
170 \ | 170 \ |
171 V(TypedArrayPrototypeBuffer) \ | 171 V(TypedArrayPrototypeBuffer, true) \ |
172 \ | 172 \ |
173 V(HandleApiCall) \ | 173 V(HandleApiCall, false) \ |
174 V(HandleApiCallAsFunction) \ | 174 V(HandleApiCallAsFunction, false) \ |
175 V(HandleApiCallAsConstructor) \ | 175 V(HandleApiCallAsConstructor, false) \ |
176 \ | 176 \ |
177 V(RestrictedFunctionPropertiesThrower) \ | 177 V(RestrictedFunctionPropertiesThrower, true) \ |
178 V(RestrictedStrictArgumentsPropertiesThrower) | 178 V(RestrictedStrictArgumentsPropertiesThrower, true) |
179 | 179 |
180 // Define list of builtins implemented in assembly. | 180 // Define list of builtins implemented in assembly. |
181 #define BUILTIN_LIST_A(V) \ | 181 #define BUILTIN_LIST_A(V) \ |
182 V(AllocateInNewSpace, BUILTIN, kNoExtraICState) \ | 182 V(AllocateInNewSpace, BUILTIN, kNoExtraICState) \ |
183 V(AllocateInOldSpace, BUILTIN, kNoExtraICState) \ | 183 V(AllocateInOldSpace, BUILTIN, kNoExtraICState) \ |
184 \ | 184 \ |
185 V(ArgumentsAdaptorTrampoline, BUILTIN, kNoExtraICState) \ | 185 V(ArgumentsAdaptorTrampoline, BUILTIN, kNoExtraICState) \ |
186 \ | 186 \ |
187 V(ConstructedNonConstructable, BUILTIN, kNoExtraICState) \ | 187 V(ConstructedNonConstructable, BUILTIN, kNoExtraICState) \ |
188 \ | 188 \ |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
367 void SetUp(Isolate* isolate, bool create_heap_objects); | 367 void SetUp(Isolate* isolate, bool create_heap_objects); |
368 void TearDown(); | 368 void TearDown(); |
369 | 369 |
370 // Garbage collection support. | 370 // Garbage collection support. |
371 void IterateBuiltins(ObjectVisitor* v); | 371 void IterateBuiltins(ObjectVisitor* v); |
372 | 372 |
373 // Disassembler support. | 373 // Disassembler support. |
374 const char* Lookup(byte* pc); | 374 const char* Lookup(byte* pc); |
375 | 375 |
376 enum Name { | 376 enum Name { |
377 #define DEF_ENUM_C(name) k##name, | 377 #define DEF_ENUM_C(name, ignore) k##name, |
378 #define DEF_ENUM_A(name, kind, extra) k##name, | 378 #define DEF_ENUM_A(name, kind, extra) k##name, |
379 #define DEF_ENUM_T(name, argc) k##name, | 379 #define DEF_ENUM_T(name, argc) k##name, |
380 #define DEF_ENUM_S(name, kind, extra, interface_descriptor) k##name, | 380 #define DEF_ENUM_S(name, kind, extra, interface_descriptor) k##name, |
381 #define DEF_ENUM_H(name, kind) k##name, | 381 #define DEF_ENUM_H(name, kind) k##name, |
382 BUILTIN_LIST_C(DEF_ENUM_C) BUILTIN_LIST_A(DEF_ENUM_A) | 382 BUILTIN_LIST_C(DEF_ENUM_C) BUILTIN_LIST_A(DEF_ENUM_A) |
383 BUILTIN_LIST_T(DEF_ENUM_T) BUILTIN_LIST_S(DEF_ENUM_S) | 383 BUILTIN_LIST_T(DEF_ENUM_T) BUILTIN_LIST_S(DEF_ENUM_S) |
384 BUILTIN_LIST_H(DEF_ENUM_H) BUILTIN_LIST_DEBUG_A(DEF_ENUM_A) | 384 BUILTIN_LIST_H(DEF_ENUM_H) BUILTIN_LIST_DEBUG_A(DEF_ENUM_A) |
385 #undef DEF_ENUM_C | 385 #undef DEF_ENUM_C |
386 #undef DEF_ENUM_A | 386 #undef DEF_ENUM_A |
387 #undef DEF_ENUM_T | 387 #undef DEF_ENUM_T |
388 #undef DEF_ENUM_S | 388 #undef DEF_ENUM_S |
389 #undef DEF_ENUM_H | 389 #undef DEF_ENUM_H |
390 builtin_count | 390 builtin_count |
391 }; | 391 }; |
392 | 392 |
393 enum CFunctionId { | 393 enum CFunctionId { |
394 #define DEF_ENUM_C(name) c_##name, | 394 #define DEF_ENUM_C(name, ignore) c_##name, |
395 BUILTIN_LIST_C(DEF_ENUM_C) | 395 BUILTIN_LIST_C(DEF_ENUM_C) |
396 #undef DEF_ENUM_C | 396 #undef DEF_ENUM_C |
397 cfunction_count | 397 cfunction_count |
398 }; | 398 }; |
399 | 399 |
400 #define DECLARE_BUILTIN_ACCESSOR_C(name) Handle<Code> name(); | 400 #define DECLARE_BUILTIN_ACCESSOR_C(name, ignore) Handle<Code> name(); |
401 #define DECLARE_BUILTIN_ACCESSOR_A(name, kind, extra) Handle<Code> name(); | 401 #define DECLARE_BUILTIN_ACCESSOR_A(name, kind, extra) Handle<Code> name(); |
402 #define DECLARE_BUILTIN_ACCESSOR_T(name, argc) Handle<Code> name(); | 402 #define DECLARE_BUILTIN_ACCESSOR_T(name, argc) Handle<Code> name(); |
403 #define DECLARE_BUILTIN_ACCESSOR_S(name, kind, extra, interface_descriptor) \ | 403 #define DECLARE_BUILTIN_ACCESSOR_S(name, kind, extra, interface_descriptor) \ |
404 Handle<Code> name(); | 404 Handle<Code> name(); |
405 #define DECLARE_BUILTIN_ACCESSOR_H(name, kind) Handle<Code> name(); | 405 #define DECLARE_BUILTIN_ACCESSOR_H(name, kind) Handle<Code> name(); |
406 BUILTIN_LIST_C(DECLARE_BUILTIN_ACCESSOR_C) | 406 BUILTIN_LIST_C(DECLARE_BUILTIN_ACCESSOR_C) |
407 BUILTIN_LIST_A(DECLARE_BUILTIN_ACCESSOR_A) | 407 BUILTIN_LIST_A(DECLARE_BUILTIN_ACCESSOR_A) |
408 BUILTIN_LIST_T(DECLARE_BUILTIN_ACCESSOR_T) | 408 BUILTIN_LIST_T(DECLARE_BUILTIN_ACCESSOR_T) |
409 BUILTIN_LIST_S(DECLARE_BUILTIN_ACCESSOR_S) | 409 BUILTIN_LIST_S(DECLARE_BUILTIN_ACCESSOR_S) |
410 BUILTIN_LIST_H(DECLARE_BUILTIN_ACCESSOR_H) | 410 BUILTIN_LIST_H(DECLARE_BUILTIN_ACCESSOR_H) |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
455 | 455 |
456 // The external C++ functions called from the code. | 456 // The external C++ functions called from the code. |
457 static Address const c_functions_[cfunction_count]; | 457 static Address const c_functions_[cfunction_count]; |
458 | 458 |
459 // Note: These are always Code objects, but to conform with | 459 // Note: These are always Code objects, but to conform with |
460 // IterateBuiltins() above which assumes Object**'s for the callback | 460 // IterateBuiltins() above which assumes Object**'s for the callback |
461 // function f, we use an Object* array here. | 461 // function f, we use an Object* array here. |
462 Object* builtins_[builtin_count]; | 462 Object* builtins_[builtin_count]; |
463 const char* names_[builtin_count]; | 463 const char* names_[builtin_count]; |
464 | 464 |
465 static void Generate_Adaptor(MacroAssembler* masm, CFunctionId id); | 465 static void Generate_Adaptor(MacroAssembler* masm, CFunctionId id, |
466 bool builtin_exit_frame); | |
466 static void Generate_AllocateInNewSpace(MacroAssembler* masm); | 467 static void Generate_AllocateInNewSpace(MacroAssembler* masm); |
467 static void Generate_AllocateInOldSpace(MacroAssembler* masm); | 468 static void Generate_AllocateInOldSpace(MacroAssembler* masm); |
468 static void Generate_ConstructedNonConstructable(MacroAssembler* masm); | 469 static void Generate_ConstructedNonConstructable(MacroAssembler* masm); |
469 static void Generate_CompileLazy(MacroAssembler* masm); | 470 static void Generate_CompileLazy(MacroAssembler* masm); |
470 static void Generate_CompileBaseline(MacroAssembler* masm); | 471 static void Generate_CompileBaseline(MacroAssembler* masm); |
471 static void Generate_InOptimizationQueue(MacroAssembler* masm); | 472 static void Generate_InOptimizationQueue(MacroAssembler* masm); |
472 static void Generate_CompileOptimized(MacroAssembler* masm); | 473 static void Generate_CompileOptimized(MacroAssembler* masm); |
473 static void Generate_CompileOptimizedConcurrent(MacroAssembler* masm); | 474 static void Generate_CompileOptimizedConcurrent(MacroAssembler* masm); |
474 static void Generate_JSConstructStubGeneric(MacroAssembler* masm); | 475 static void Generate_JSConstructStubGeneric(MacroAssembler* masm); |
475 static void Generate_JSBuiltinsConstructStub(MacroAssembler* masm); | 476 static void Generate_JSBuiltinsConstructStub(MacroAssembler* masm); |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
748 friend class BuiltinFunctionTable; | 749 friend class BuiltinFunctionTable; |
749 friend class Isolate; | 750 friend class Isolate; |
750 | 751 |
751 DISALLOW_COPY_AND_ASSIGN(Builtins); | 752 DISALLOW_COPY_AND_ASSIGN(Builtins); |
752 }; | 753 }; |
753 | 754 |
754 } // namespace internal | 755 } // namespace internal |
755 } // namespace v8 | 756 } // namespace v8 |
756 | 757 |
757 #endif // V8_BUILTINS_H_ | 758 #endif // V8_BUILTINS_H_ |
OLD | NEW |