2011-05-18 13:17:29 +00:00
|
|
|
// Copyright 2011 the V8 project authors. All rights reserved.
|
2014-04-29 06:42:26 +00:00
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
#ifndef V8_BUILTINS_H_
|
|
|
|
#define V8_BUILTINS_H_
|
|
|
|
|
2009-05-25 10:05:56 +00:00
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2010-01-15 12:25:24 +00:00
|
|
|
// Specifies extra arguments required by a C++ builtin.
|
|
|
|
enum BuiltinExtraArguments {
|
|
|
|
NO_EXTRA_ARGUMENTS = 0,
|
|
|
|
NEEDS_CALLED_FUNCTION = 1
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-11-08 12:18:11 +00:00
|
|
|
#define CODE_AGE_LIST_WITH_ARG(V, A) \
|
|
|
|
V(Quadragenarian, A) \
|
|
|
|
V(Quinquagenarian, A) \
|
|
|
|
V(Sexagenarian, A) \
|
|
|
|
V(Septuagenarian, A) \
|
|
|
|
V(Octogenarian, A)
|
|
|
|
|
|
|
|
#define CODE_AGE_LIST_IGNORE_ARG(X, V) V(X)
|
|
|
|
|
|
|
|
#define CODE_AGE_LIST(V) \
|
|
|
|
CODE_AGE_LIST_WITH_ARG(CODE_AGE_LIST_IGNORE_ARG, V)
|
|
|
|
|
2013-11-06 09:29:09 +00:00
|
|
|
#define CODE_AGE_LIST_COMPLETE(V) \
|
|
|
|
V(NotExecuted) \
|
|
|
|
V(ExecutedOnce) \
|
2013-10-24 10:50:35 +00:00
|
|
|
V(NoAge) \
|
|
|
|
CODE_AGE_LIST_WITH_ARG(CODE_AGE_LIST_IGNORE_ARG, V)
|
|
|
|
|
2012-11-08 12:18:11 +00:00
|
|
|
#define DECLARE_CODE_AGE_BUILTIN(C, V) \
|
|
|
|
V(Make##C##CodeYoungAgainOddMarking, BUILTIN, \
|
2013-11-28 15:32:55 +00:00
|
|
|
UNINITIALIZED, kNoExtraICState) \
|
2012-11-08 12:18:11 +00:00
|
|
|
V(Make##C##CodeYoungAgainEvenMarking, BUILTIN, \
|
2013-11-28 15:32:55 +00:00
|
|
|
UNINITIALIZED, kNoExtraICState)
|
2012-11-08 12:18:11 +00:00
|
|
|
|
|
|
|
|
2010-01-15 12:25:24 +00:00
|
|
|
// Define list of builtins implemented in C++.
|
|
|
|
#define BUILTIN_LIST_C(V) \
|
|
|
|
V(Illegal, NO_EXTRA_ARGUMENTS) \
|
|
|
|
\
|
|
|
|
V(EmptyFunction, NO_EXTRA_ARGUMENTS) \
|
|
|
|
\
|
|
|
|
V(ArrayPush, NO_EXTRA_ARGUMENTS) \
|
|
|
|
V(ArrayPop, NO_EXTRA_ARGUMENTS) \
|
2010-02-15 09:17:38 +00:00
|
|
|
V(ArrayShift, NO_EXTRA_ARGUMENTS) \
|
2010-02-15 13:25:06 +00:00
|
|
|
V(ArrayUnshift, NO_EXTRA_ARGUMENTS) \
|
2010-02-16 12:14:23 +00:00
|
|
|
V(ArraySlice, NO_EXTRA_ARGUMENTS) \
|
2010-02-17 10:54:49 +00:00
|
|
|
V(ArraySplice, NO_EXTRA_ARGUMENTS) \
|
2010-03-15 10:52:38 +00:00
|
|
|
V(ArrayConcat, NO_EXTRA_ARGUMENTS) \
|
2010-01-15 12:25:24 +00:00
|
|
|
\
|
|
|
|
V(HandleApiCall, NEEDS_CALLED_FUNCTION) \
|
|
|
|
V(HandleApiCallConstruct, NEEDS_CALLED_FUNCTION) \
|
|
|
|
V(HandleApiCallAsFunction, NO_EXTRA_ARGUMENTS) \
|
2011-03-17 20:28:17 +00:00
|
|
|
V(HandleApiCallAsConstructor, NO_EXTRA_ARGUMENTS) \
|
|
|
|
\
|
2014-05-19 10:47:00 +00:00
|
|
|
V(StrictModePoisonPill, NO_EXTRA_ARGUMENTS) \
|
|
|
|
V(GeneratorPoisonPill, NO_EXTRA_ARGUMENTS)
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Define list of builtins implemented in assembly.
|
2011-05-18 13:17:29 +00:00
|
|
|
#define BUILTIN_LIST_A(V) \
|
|
|
|
V(ArgumentsAdaptorTrampoline, BUILTIN, UNINITIALIZED, \
|
2013-11-28 15:32:55 +00:00
|
|
|
kNoExtraICState) \
|
2013-12-23 14:30:35 +00:00
|
|
|
V(InOptimizationQueue, BUILTIN, UNINITIALIZED, \
|
2013-11-28 15:32:55 +00:00
|
|
|
kNoExtraICState) \
|
2011-05-18 13:17:29 +00:00
|
|
|
V(JSConstructStubGeneric, BUILTIN, UNINITIALIZED, \
|
2013-11-28 15:32:55 +00:00
|
|
|
kNoExtraICState) \
|
2011-05-18 13:17:29 +00:00
|
|
|
V(JSConstructStubApi, BUILTIN, UNINITIALIZED, \
|
2013-11-28 15:32:55 +00:00
|
|
|
kNoExtraICState) \
|
2011-05-18 13:17:29 +00:00
|
|
|
V(JSEntryTrampoline, BUILTIN, UNINITIALIZED, \
|
2013-11-28 15:32:55 +00:00
|
|
|
kNoExtraICState) \
|
2011-05-18 13:17:29 +00:00
|
|
|
V(JSConstructEntryTrampoline, BUILTIN, UNINITIALIZED, \
|
2013-11-28 15:32:55 +00:00
|
|
|
kNoExtraICState) \
|
2013-12-23 14:30:35 +00:00
|
|
|
V(CompileUnoptimized, BUILTIN, UNINITIALIZED, \
|
2013-11-28 15:32:55 +00:00
|
|
|
kNoExtraICState) \
|
2013-12-23 14:30:35 +00:00
|
|
|
V(CompileOptimized, BUILTIN, UNINITIALIZED, \
|
2013-11-28 15:32:55 +00:00
|
|
|
kNoExtraICState) \
|
2013-12-23 14:30:35 +00:00
|
|
|
V(CompileOptimizedConcurrent, BUILTIN, UNINITIALIZED, \
|
2013-11-28 15:32:55 +00:00
|
|
|
kNoExtraICState) \
|
2011-05-18 13:17:29 +00:00
|
|
|
V(NotifyDeoptimized, BUILTIN, UNINITIALIZED, \
|
2013-11-28 15:32:55 +00:00
|
|
|
kNoExtraICState) \
|
2013-05-14 11:45:33 +00:00
|
|
|
V(NotifySoftDeoptimized, BUILTIN, UNINITIALIZED, \
|
2013-11-28 15:32:55 +00:00
|
|
|
kNoExtraICState) \
|
2011-05-18 13:17:29 +00:00
|
|
|
V(NotifyLazyDeoptimized, BUILTIN, UNINITIALIZED, \
|
2013-11-28 15:32:55 +00:00
|
|
|
kNoExtraICState) \
|
2013-01-07 10:06:11 +00:00
|
|
|
V(NotifyStubFailure, BUILTIN, UNINITIALIZED, \
|
2013-11-28 15:32:55 +00:00
|
|
|
kNoExtraICState) \
|
2013-11-22 10:21:47 +00:00
|
|
|
V(NotifyStubFailureSaveDoubles, BUILTIN, UNINITIALIZED, \
|
2013-11-28 15:32:55 +00:00
|
|
|
kNoExtraICState) \
|
2011-05-18 13:17:29 +00:00
|
|
|
\
|
|
|
|
V(LoadIC_Miss, BUILTIN, UNINITIALIZED, \
|
2013-11-28 15:32:55 +00:00
|
|
|
kNoExtraICState) \
|
2011-05-18 13:17:29 +00:00
|
|
|
V(KeyedLoadIC_Miss, BUILTIN, UNINITIALIZED, \
|
2013-11-28 15:32:55 +00:00
|
|
|
kNoExtraICState) \
|
2011-05-18 13:17:29 +00:00
|
|
|
V(StoreIC_Miss, BUILTIN, UNINITIALIZED, \
|
2013-11-28 15:32:55 +00:00
|
|
|
kNoExtraICState) \
|
2011-05-18 13:17:29 +00:00
|
|
|
V(KeyedStoreIC_Miss, BUILTIN, UNINITIALIZED, \
|
2013-11-28 15:32:55 +00:00
|
|
|
kNoExtraICState) \
|
2012-09-07 09:01:54 +00:00
|
|
|
V(LoadIC_Getter_ForDeopt, LOAD_IC, MONOMORPHIC, \
|
2013-11-28 15:32:55 +00:00
|
|
|
kNoExtraICState) \
|
2011-05-18 13:17:29 +00:00
|
|
|
V(KeyedLoadIC_Initialize, KEYED_LOAD_IC, UNINITIALIZED, \
|
2013-11-28 15:32:55 +00:00
|
|
|
kNoExtraICState) \
|
2011-05-18 13:17:29 +00:00
|
|
|
V(KeyedLoadIC_PreMonomorphic, KEYED_LOAD_IC, PREMONOMORPHIC, \
|
2013-11-28 15:32:55 +00:00
|
|
|
kNoExtraICState) \
|
2013-01-16 15:02:58 +00:00
|
|
|
V(KeyedLoadIC_Generic, KEYED_LOAD_IC, GENERIC, \
|
2013-11-28 15:32:55 +00:00
|
|
|
kNoExtraICState) \
|
2013-02-04 13:12:03 +00:00
|
|
|
V(KeyedLoadIC_String, KEYED_LOAD_IC, MEGAMORPHIC, \
|
2013-11-28 15:32:55 +00:00
|
|
|
kNoExtraICState) \
|
2013-01-29 12:00:56 +00:00
|
|
|
V(KeyedLoadIC_IndexedInterceptor, KEYED_LOAD_IC, MONOMORPHIC, \
|
2013-11-28 15:32:55 +00:00
|
|
|
kNoExtraICState) \
|
2014-03-11 14:39:08 +00:00
|
|
|
V(KeyedLoadIC_SloppyArguments, KEYED_LOAD_IC, MONOMORPHIC, \
|
2013-11-28 15:32:55 +00:00
|
|
|
kNoExtraICState) \
|
2011-05-18 13:17:29 +00:00
|
|
|
\
|
2012-08-17 10:43:32 +00:00
|
|
|
V(StoreIC_Setter_ForDeopt, STORE_IC, MONOMORPHIC, \
|
2013-11-28 15:32:55 +00:00
|
|
|
StoreIC::kStrictModeState) \
|
2011-05-18 13:17:29 +00:00
|
|
|
\
|
|
|
|
V(KeyedStoreIC_Initialize, KEYED_STORE_IC, UNINITIALIZED, \
|
2013-11-28 15:32:55 +00:00
|
|
|
kNoExtraICState) \
|
2013-09-03 13:33:54 +00:00
|
|
|
V(KeyedStoreIC_PreMonomorphic, KEYED_STORE_IC, PREMONOMORPHIC, \
|
2013-11-28 15:32:55 +00:00
|
|
|
kNoExtraICState) \
|
2013-01-16 15:02:58 +00:00
|
|
|
V(KeyedStoreIC_Generic, KEYED_STORE_IC, GENERIC, \
|
2013-11-28 15:32:55 +00:00
|
|
|
kNoExtraICState) \
|
2011-05-18 13:17:29 +00:00
|
|
|
\
|
|
|
|
V(KeyedStoreIC_Initialize_Strict, KEYED_STORE_IC, UNINITIALIZED, \
|
2013-11-28 15:32:55 +00:00
|
|
|
StoreIC::kStrictModeState) \
|
2013-09-03 13:33:54 +00:00
|
|
|
V(KeyedStoreIC_PreMonomorphic_Strict, KEYED_STORE_IC, PREMONOMORPHIC, \
|
2013-11-28 15:32:55 +00:00
|
|
|
StoreIC::kStrictModeState) \
|
2013-01-16 15:02:58 +00:00
|
|
|
V(KeyedStoreIC_Generic_Strict, KEYED_STORE_IC, GENERIC, \
|
2013-11-28 15:32:55 +00:00
|
|
|
StoreIC::kStrictModeState) \
|
2014-03-11 14:39:08 +00:00
|
|
|
V(KeyedStoreIC_SloppyArguments, KEYED_STORE_IC, MONOMORPHIC, \
|
|
|
|
kNoExtraICState) \
|
2011-05-18 13:17:29 +00:00
|
|
|
\
|
|
|
|
/* Uses KeyedLoadIC_Initialize; must be after in list. */ \
|
|
|
|
V(FunctionCall, BUILTIN, UNINITIALIZED, \
|
2013-11-28 15:32:55 +00:00
|
|
|
kNoExtraICState) \
|
2011-05-18 13:17:29 +00:00
|
|
|
V(FunctionApply, BUILTIN, UNINITIALIZED, \
|
2013-11-28 15:32:55 +00:00
|
|
|
kNoExtraICState) \
|
2011-05-18 13:17:29 +00:00
|
|
|
\
|
2011-12-27 15:12:12 +00:00
|
|
|
V(InternalArrayCode, BUILTIN, UNINITIALIZED, \
|
2013-11-28 15:32:55 +00:00
|
|
|
kNoExtraICState) \
|
2011-05-18 13:17:29 +00:00
|
|
|
V(ArrayCode, BUILTIN, UNINITIALIZED, \
|
2013-11-28 15:32:55 +00:00
|
|
|
kNoExtraICState) \
|
2011-05-18 13:17:29 +00:00
|
|
|
\
|
|
|
|
V(StringConstructCode, BUILTIN, UNINITIALIZED, \
|
2013-11-28 15:32:55 +00:00
|
|
|
kNoExtraICState) \
|
2011-05-18 13:17:29 +00:00
|
|
|
\
|
|
|
|
V(OnStackReplacement, BUILTIN, UNINITIALIZED, \
|
2013-11-28 15:32:55 +00:00
|
|
|
kNoExtraICState) \
|
2013-08-30 11:24:58 +00:00
|
|
|
V(InterruptCheck, BUILTIN, UNINITIALIZED, \
|
2013-11-28 15:32:55 +00:00
|
|
|
kNoExtraICState) \
|
2013-09-25 08:26:11 +00:00
|
|
|
V(OsrAfterStackCheck, BUILTIN, UNINITIALIZED, \
|
2013-11-28 15:32:55 +00:00
|
|
|
kNoExtraICState) \
|
2013-08-30 11:24:58 +00:00
|
|
|
V(StackCheck, BUILTIN, UNINITIALIZED, \
|
2013-11-28 15:32:55 +00:00
|
|
|
kNoExtraICState) \
|
2013-10-23 13:48:04 +00:00
|
|
|
\
|
|
|
|
V(MarkCodeAsExecutedOnce, BUILTIN, UNINITIALIZED, \
|
2013-11-28 15:32:55 +00:00
|
|
|
kNoExtraICState) \
|
2013-10-23 13:48:04 +00:00
|
|
|
V(MarkCodeAsExecutedTwice, BUILTIN, UNINITIALIZED, \
|
2013-11-28 15:32:55 +00:00
|
|
|
kNoExtraICState) \
|
2012-11-08 12:18:11 +00:00
|
|
|
CODE_AGE_LIST_WITH_ARG(DECLARE_CODE_AGE_BUILTIN, V)
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2013-09-30 13:58:44 +00:00
|
|
|
// Define list of builtin handlers implemented in assembly.
|
2013-11-27 14:00:54 +00:00
|
|
|
#define BUILTIN_LIST_H(V) \
|
|
|
|
V(LoadIC_Slow, LOAD_IC) \
|
|
|
|
V(KeyedLoadIC_Slow, KEYED_LOAD_IC) \
|
|
|
|
V(StoreIC_Slow, STORE_IC) \
|
|
|
|
V(KeyedStoreIC_Slow, KEYED_STORE_IC) \
|
|
|
|
V(LoadIC_Normal, LOAD_IC) \
|
|
|
|
V(StoreIC_Normal, STORE_IC)
|
2013-09-30 13:58:44 +00:00
|
|
|
|
2008-12-08 10:16:57 +00:00
|
|
|
// Define list of builtins used by the debugger implemented in assembly.
|
2013-01-10 14:15:12 +00:00
|
|
|
#define BUILTIN_LIST_DEBUG_A(V) \
|
|
|
|
V(Return_DebugBreak, BUILTIN, DEBUG_STUB, \
|
|
|
|
DEBUG_BREAK) \
|
|
|
|
V(CallFunctionStub_DebugBreak, BUILTIN, DEBUG_STUB, \
|
|
|
|
DEBUG_BREAK) \
|
|
|
|
V(CallConstructStub_DebugBreak, BUILTIN, DEBUG_STUB, \
|
|
|
|
DEBUG_BREAK) \
|
|
|
|
V(CallConstructStub_Recording_DebugBreak, BUILTIN, DEBUG_STUB, \
|
|
|
|
DEBUG_BREAK) \
|
2014-04-30 14:33:35 +00:00
|
|
|
V(CallICStub_DebugBreak, CALL_IC, DEBUG_STUB, \
|
|
|
|
DEBUG_BREAK) \
|
2013-01-10 14:15:12 +00:00
|
|
|
V(LoadIC_DebugBreak, LOAD_IC, DEBUG_STUB, \
|
|
|
|
DEBUG_BREAK) \
|
|
|
|
V(KeyedLoadIC_DebugBreak, KEYED_LOAD_IC, DEBUG_STUB, \
|
|
|
|
DEBUG_BREAK) \
|
|
|
|
V(StoreIC_DebugBreak, STORE_IC, DEBUG_STUB, \
|
|
|
|
DEBUG_BREAK) \
|
|
|
|
V(KeyedStoreIC_DebugBreak, KEYED_STORE_IC, DEBUG_STUB, \
|
|
|
|
DEBUG_BREAK) \
|
2013-04-30 07:56:09 +00:00
|
|
|
V(CompareNilIC_DebugBreak, COMPARE_NIL_IC, DEBUG_STUB, \
|
|
|
|
DEBUG_BREAK) \
|
2013-01-10 14:15:12 +00:00
|
|
|
V(Slot_DebugBreak, BUILTIN, DEBUG_STUB, \
|
|
|
|
DEBUG_BREAK) \
|
|
|
|
V(PlainReturn_LiveEdit, BUILTIN, DEBUG_STUB, \
|
|
|
|
DEBUG_BREAK) \
|
|
|
|
V(FrameDropper_LiveEdit, BUILTIN, DEBUG_STUB, \
|
|
|
|
DEBUG_BREAK)
|
2008-12-08 10:16:57 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Define list of builtins implemented in JavaScript.
|
2009-05-20 19:33:44 +00:00
|
|
|
#define BUILTINS_LIST_JS(V) \
|
|
|
|
V(EQUALS, 1) \
|
|
|
|
V(STRICT_EQUALS, 1) \
|
|
|
|
V(COMPARE, 2) \
|
|
|
|
V(ADD, 1) \
|
|
|
|
V(SUB, 1) \
|
|
|
|
V(MUL, 1) \
|
|
|
|
V(DIV, 1) \
|
|
|
|
V(MOD, 1) \
|
|
|
|
V(BIT_OR, 1) \
|
|
|
|
V(BIT_AND, 1) \
|
|
|
|
V(BIT_XOR, 1) \
|
|
|
|
V(SHL, 1) \
|
|
|
|
V(SAR, 1) \
|
|
|
|
V(SHR, 1) \
|
2011-02-14 23:41:47 +00:00
|
|
|
V(DELETE, 2) \
|
2009-05-20 19:33:44 +00:00
|
|
|
V(IN, 1) \
|
|
|
|
V(INSTANCE_OF, 1) \
|
|
|
|
V(FILTER_KEY, 1) \
|
|
|
|
V(CALL_NON_FUNCTION, 0) \
|
|
|
|
V(CALL_NON_FUNCTION_AS_CONSTRUCTOR, 0) \
|
2011-09-13 11:42:57 +00:00
|
|
|
V(CALL_FUNCTION_PROXY, 1) \
|
|
|
|
V(CALL_FUNCTION_PROXY_AS_CONSTRUCTOR, 1) \
|
2009-05-20 19:33:44 +00:00
|
|
|
V(TO_OBJECT, 0) \
|
|
|
|
V(TO_NUMBER, 0) \
|
|
|
|
V(TO_STRING, 0) \
|
|
|
|
V(STRING_ADD_LEFT, 1) \
|
|
|
|
V(STRING_ADD_RIGHT, 1) \
|
|
|
|
V(APPLY_PREPARE, 1) \
|
2014-04-15 08:26:26 +00:00
|
|
|
V(STACK_OVERFLOW, 1)
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2011-03-18 20:35:07 +00:00
|
|
|
class BuiltinFunctionTable;
|
2008-07-03 15:10:15 +00:00
|
|
|
class ObjectVisitor;
|
|
|
|
|
|
|
|
|
2011-03-18 20:35:07 +00:00
|
|
|
class Builtins {
|
2008-07-03 15:10:15 +00:00
|
|
|
public:
|
2011-03-18 20:35:07 +00:00
|
|
|
~Builtins();
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Generate all builtin code objects. Should be called once during
|
2011-03-18 20:35:07 +00:00
|
|
|
// isolate initialization.
|
2013-09-03 06:57:16 +00:00
|
|
|
void SetUp(Isolate* isolate, bool create_heap_objects);
|
2011-03-18 20:35:07 +00:00
|
|
|
void TearDown();
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Garbage collection support.
|
2011-03-18 20:35:07 +00:00
|
|
|
void IterateBuiltins(ObjectVisitor* v);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Disassembler support.
|
2011-03-18 20:35:07 +00:00
|
|
|
const char* Lookup(byte* pc);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
enum Name {
|
2011-03-23 13:40:07 +00:00
|
|
|
#define DEF_ENUM_C(name, ignore) k##name,
|
|
|
|
#define DEF_ENUM_A(name, kind, state, extra) k##name,
|
2013-11-27 14:00:54 +00:00
|
|
|
#define DEF_ENUM_H(name, kind) k##name,
|
2008-07-03 15:10:15 +00:00
|
|
|
BUILTIN_LIST_C(DEF_ENUM_C)
|
|
|
|
BUILTIN_LIST_A(DEF_ENUM_A)
|
2013-09-30 13:58:44 +00:00
|
|
|
BUILTIN_LIST_H(DEF_ENUM_H)
|
2008-12-08 10:16:57 +00:00
|
|
|
BUILTIN_LIST_DEBUG_A(DEF_ENUM_A)
|
2008-07-03 15:10:15 +00:00
|
|
|
#undef DEF_ENUM_C
|
|
|
|
#undef DEF_ENUM_A
|
|
|
|
builtin_count
|
|
|
|
};
|
|
|
|
|
|
|
|
enum CFunctionId {
|
2010-01-15 12:25:24 +00:00
|
|
|
#define DEF_ENUM_C(name, ignore) c_##name,
|
2008-07-03 15:10:15 +00:00
|
|
|
BUILTIN_LIST_C(DEF_ENUM_C)
|
|
|
|
#undef DEF_ENUM_C
|
|
|
|
cfunction_count
|
|
|
|
};
|
|
|
|
|
|
|
|
enum JavaScript {
|
|
|
|
#define DEF_ENUM(name, ignore) name,
|
|
|
|
BUILTINS_LIST_JS(DEF_ENUM)
|
|
|
|
#undef DEF_ENUM
|
|
|
|
id_count
|
|
|
|
};
|
|
|
|
|
2011-03-23 13:40:07 +00:00
|
|
|
#define DECLARE_BUILTIN_ACCESSOR_C(name, ignore) Handle<Code> name();
|
|
|
|
#define DECLARE_BUILTIN_ACCESSOR_A(name, kind, state, extra) \
|
|
|
|
Handle<Code> name();
|
2013-11-27 14:00:54 +00:00
|
|
|
#define DECLARE_BUILTIN_ACCESSOR_H(name, kind) Handle<Code> name();
|
2011-03-23 13:40:07 +00:00
|
|
|
BUILTIN_LIST_C(DECLARE_BUILTIN_ACCESSOR_C)
|
|
|
|
BUILTIN_LIST_A(DECLARE_BUILTIN_ACCESSOR_A)
|
2013-09-30 13:58:44 +00:00
|
|
|
BUILTIN_LIST_H(DECLARE_BUILTIN_ACCESSOR_H)
|
2011-03-23 13:40:07 +00:00
|
|
|
BUILTIN_LIST_DEBUG_A(DECLARE_BUILTIN_ACCESSOR_A)
|
|
|
|
#undef DECLARE_BUILTIN_ACCESSOR_C
|
|
|
|
#undef DECLARE_BUILTIN_ACCESSOR_A
|
|
|
|
|
2011-03-18 20:35:07 +00:00
|
|
|
Code* builtin(Name name) {
|
2008-07-03 15:10:15 +00:00
|
|
|
// Code::cast cannot be used here since we access builtins
|
|
|
|
// during the marking phase of mark sweep. See IC::Clear.
|
|
|
|
return reinterpret_cast<Code*>(builtins_[name]);
|
|
|
|
}
|
|
|
|
|
2011-03-18 20:35:07 +00:00
|
|
|
Address builtin_address(Name name) {
|
2008-07-03 15:10:15 +00:00
|
|
|
return reinterpret_cast<Address>(&builtins_[name]);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Address c_function_address(CFunctionId id) {
|
|
|
|
return c_functions_[id];
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char* GetName(JavaScript id) { return javascript_names_[id]; }
|
2013-11-05 13:23:03 +00:00
|
|
|
const char* name(int index) {
|
2014-08-04 11:34:54 +00:00
|
|
|
DCHECK(index >= 0);
|
|
|
|
DCHECK(index < builtin_count);
|
2013-11-05 13:23:03 +00:00
|
|
|
return names_[index];
|
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
static int GetArgumentsCount(JavaScript id) { return javascript_argc_[id]; }
|
2011-03-18 20:35:07 +00:00
|
|
|
Handle<Code> GetCode(JavaScript id, bool* resolved);
|
2008-07-03 15:10:15 +00:00
|
|
|
static int NumberOfJavaScriptBuiltins() { return id_count; }
|
|
|
|
|
2011-03-18 20:35:07 +00:00
|
|
|
bool is_initialized() const { return initialized_; }
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
private:
|
2011-03-18 20:35:07 +00:00
|
|
|
Builtins();
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// The external C++ functions called from the code.
|
2011-03-18 20:35:07 +00:00
|
|
|
static Address const c_functions_[cfunction_count];
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Note: These are always Code objects, but to conform with
|
|
|
|
// IterateBuiltins() above which assumes Object**'s for the callback
|
|
|
|
// function f, we use an Object* array here.
|
2011-03-18 20:35:07 +00:00
|
|
|
Object* builtins_[builtin_count];
|
|
|
|
const char* names_[builtin_count];
|
|
|
|
static const char* const javascript_names_[id_count];
|
|
|
|
static int const javascript_argc_[id_count];
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2010-01-15 12:25:24 +00:00
|
|
|
static void Generate_Adaptor(MacroAssembler* masm,
|
|
|
|
CFunctionId id,
|
|
|
|
BuiltinExtraArguments extra_args);
|
2013-12-23 14:30:35 +00:00
|
|
|
static void Generate_CompileUnoptimized(MacroAssembler* masm);
|
|
|
|
static void Generate_InOptimizationQueue(MacroAssembler* masm);
|
|
|
|
static void Generate_CompileOptimized(MacroAssembler* masm);
|
|
|
|
static void Generate_CompileOptimizedConcurrent(MacroAssembler* masm);
|
2009-06-19 07:36:16 +00:00
|
|
|
static void Generate_JSConstructStubGeneric(MacroAssembler* masm);
|
2010-01-15 12:25:24 +00:00
|
|
|
static void Generate_JSConstructStubApi(MacroAssembler* masm);
|
2008-07-03 15:10:15 +00:00
|
|
|
static void Generate_JSEntryTrampoline(MacroAssembler* masm);
|
|
|
|
static void Generate_JSConstructEntryTrampoline(MacroAssembler* masm);
|
2010-12-07 11:31:57 +00:00
|
|
|
static void Generate_NotifyDeoptimized(MacroAssembler* masm);
|
2013-05-14 11:45:33 +00:00
|
|
|
static void Generate_NotifySoftDeoptimized(MacroAssembler* masm);
|
2010-12-07 11:31:57 +00:00
|
|
|
static void Generate_NotifyLazyDeoptimized(MacroAssembler* masm);
|
2013-01-07 10:06:11 +00:00
|
|
|
static void Generate_NotifyStubFailure(MacroAssembler* masm);
|
2013-11-22 10:21:47 +00:00
|
|
|
static void Generate_NotifyStubFailureSaveDoubles(MacroAssembler* masm);
|
2008-07-03 15:10:15 +00:00
|
|
|
static void Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm);
|
2008-09-15 15:02:38 +00:00
|
|
|
|
|
|
|
static void Generate_FunctionCall(MacroAssembler* masm);
|
2008-07-03 15:10:15 +00:00
|
|
|
static void Generate_FunctionApply(MacroAssembler* masm);
|
2009-09-16 11:17:57 +00:00
|
|
|
|
2011-12-27 15:12:12 +00:00
|
|
|
static void Generate_InternalArrayCode(MacroAssembler* masm);
|
2009-09-16 11:17:57 +00:00
|
|
|
static void Generate_ArrayCode(MacroAssembler* masm);
|
2010-08-26 13:59:37 +00:00
|
|
|
|
|
|
|
static void Generate_StringConstructCode(MacroAssembler* masm);
|
2011-03-18 19:41:05 +00:00
|
|
|
static void Generate_OnStackReplacement(MacroAssembler* masm);
|
2013-09-25 08:26:11 +00:00
|
|
|
static void Generate_OsrAfterStackCheck(MacroAssembler* masm);
|
2013-08-30 11:24:58 +00:00
|
|
|
static void Generate_InterruptCheck(MacroAssembler* masm);
|
|
|
|
static void Generate_StackCheck(MacroAssembler* masm);
|
|
|
|
|
2012-11-08 12:18:11 +00:00
|
|
|
#define DECLARE_CODE_AGE_BUILTIN_GENERATOR(C) \
|
|
|
|
static void Generate_Make##C##CodeYoungAgainEvenMarking( \
|
|
|
|
MacroAssembler* masm); \
|
|
|
|
static void Generate_Make##C##CodeYoungAgainOddMarking( \
|
|
|
|
MacroAssembler* masm);
|
|
|
|
CODE_AGE_LIST(DECLARE_CODE_AGE_BUILTIN_GENERATOR)
|
|
|
|
#undef DECLARE_CODE_AGE_BUILTIN_GENERATOR
|
|
|
|
|
2013-10-23 13:48:04 +00:00
|
|
|
static void Generate_MarkCodeAsExecutedOnce(MacroAssembler* masm);
|
|
|
|
static void Generate_MarkCodeAsExecutedTwice(MacroAssembler* masm);
|
|
|
|
|
2011-03-18 20:35:07 +00:00
|
|
|
static void InitBuiltinFunctionTable();
|
|
|
|
|
|
|
|
bool initialized_;
|
|
|
|
|
|
|
|
friend class BuiltinFunctionTable;
|
|
|
|
friend class Isolate;
|
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(Builtins);
|
2008-07-03 15:10:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} } // namespace v8::internal
|
|
|
|
|
|
|
|
#endif // V8_BUILTINS_H_
|