2014-09-11 13:18:58 +00:00
|
|
|
// Copyright 2012 the V8 project authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#ifndef V8_CODE_FACTORY_H_
|
|
|
|
#define V8_CODE_FACTORY_H_
|
|
|
|
|
|
|
|
#include "src/allocation.h"
|
|
|
|
#include "src/assembler.h"
|
|
|
|
#include "src/codegen.h"
|
|
|
|
#include "src/globals.h"
|
|
|
|
#include "src/interface-descriptors.h"
|
|
|
|
|
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
|
|
|
|
|
|
|
// Associates a body of code with an interface descriptor.
|
2015-04-20 13:08:11 +00:00
|
|
|
class Callable final BASE_EMBEDDED {
|
2014-09-11 13:18:58 +00:00
|
|
|
public:
|
|
|
|
Callable(Handle<Code> code, CallInterfaceDescriptor descriptor)
|
|
|
|
: code_(code), descriptor_(descriptor) {}
|
|
|
|
|
|
|
|
Handle<Code> code() const { return code_; }
|
|
|
|
CallInterfaceDescriptor descriptor() const { return descriptor_; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
const Handle<Code> code_;
|
|
|
|
const CallInterfaceDescriptor descriptor_;
|
|
|
|
};
|
|
|
|
|
2016-10-17 10:01:42 +00:00
|
|
|
class V8_EXPORT_PRIVATE CodeFactory final {
|
2014-09-11 13:18:58 +00:00
|
|
|
public:
|
|
|
|
// Initial states for ICs.
|
2016-06-14 13:20:42 +00:00
|
|
|
static Callable LoadIC(Isolate* isolate);
|
|
|
|
static Callable LoadICInOptimizedCode(Isolate* isolate);
|
|
|
|
static Callable LoadGlobalIC(Isolate* isolate, TypeofMode typeof_mode);
|
|
|
|
static Callable LoadGlobalICInOptimizedCode(Isolate* isolate,
|
|
|
|
TypeofMode typeof_mode);
|
2016-02-17 10:30:10 +00:00
|
|
|
static Callable KeyedLoadIC(Isolate* isolate);
|
2016-05-30 19:26:02 +00:00
|
|
|
static Callable KeyedLoadICInOptimizedCode(Isolate* isolate);
|
2016-07-26 17:51:25 +00:00
|
|
|
static Callable KeyedLoadIC_Megamorphic(Isolate* isolate);
|
2016-10-12 09:25:55 +00:00
|
|
|
static Callable CallIC(Isolate* isolate,
|
2016-01-26 11:07:15 +00:00
|
|
|
ConvertReceiverMode mode = ConvertReceiverMode::kAny,
|
|
|
|
TailCallMode tail_call_mode = TailCallMode::kDisallow);
|
2015-11-09 08:47:59 +00:00
|
|
|
static Callable CallICInOptimizedCode(
|
2016-10-12 09:25:55 +00:00
|
|
|
Isolate* isolate, ConvertReceiverMode mode = ConvertReceiverMode::kAny,
|
2016-01-26 11:07:15 +00:00
|
|
|
TailCallMode tail_call_mode = TailCallMode::kDisallow);
|
2015-02-04 09:34:05 +00:00
|
|
|
static Callable StoreIC(Isolate* isolate, LanguageMode mode);
|
2016-05-30 19:26:02 +00:00
|
|
|
static Callable StoreICInOptimizedCode(Isolate* isolate, LanguageMode mode);
|
2015-02-04 09:34:05 +00:00
|
|
|
static Callable KeyedStoreIC(Isolate* isolate, LanguageMode mode);
|
2016-05-30 19:26:02 +00:00
|
|
|
static Callable KeyedStoreICInOptimizedCode(Isolate* isolate,
|
|
|
|
LanguageMode mode);
|
2016-10-19 10:11:25 +00:00
|
|
|
static Callable KeyedStoreIC_Megamorphic(Isolate* isolate, LanguageMode mode);
|
2014-09-11 13:18:58 +00:00
|
|
|
|
2016-04-06 08:37:09 +00:00
|
|
|
static Callable ResumeGenerator(Isolate* isolate);
|
|
|
|
|
2016-02-16 13:54:51 +00:00
|
|
|
static Callable CompareIC(Isolate* isolate, Token::Value op);
|
2015-10-27 11:21:23 +00:00
|
|
|
static Callable CompareNilIC(Isolate* isolate, NilValue nil_value);
|
2014-09-11 13:18:58 +00:00
|
|
|
|
2016-02-16 13:54:51 +00:00
|
|
|
static Callable BinaryOpIC(Isolate* isolate, Token::Value op);
|
2014-09-11 13:18:58 +00:00
|
|
|
|
2016-04-19 12:11:05 +00:00
|
|
|
static Callable ApiGetter(Isolate* isolate);
|
|
|
|
|
2014-09-11 13:18:58 +00:00
|
|
|
// Code stubs. Add methods here as needed to reduce dependency on
|
|
|
|
// code-stubs.h.
|
2015-08-25 04:48:36 +00:00
|
|
|
static Callable InstanceOf(Isolate* isolate);
|
2016-11-18 06:30:57 +00:00
|
|
|
static Callable OrdinaryHasInstance(Isolate* isolate);
|
2015-06-22 12:15:55 +00:00
|
|
|
|
2016-11-07 21:26:18 +00:00
|
|
|
static Callable StringFromCharCode(Isolate* isolate);
|
|
|
|
|
2016-07-14 10:25:45 +00:00
|
|
|
static Callable GetProperty(Isolate* isolate);
|
|
|
|
|
2015-12-02 15:21:47 +00:00
|
|
|
static Callable ToBoolean(Isolate* isolate);
|
2014-09-11 13:18:58 +00:00
|
|
|
|
|
|
|
static Callable ToNumber(Isolate* isolate);
|
2016-03-21 09:05:21 +00:00
|
|
|
static Callable NonNumberToNumber(Isolate* isolate);
|
|
|
|
static Callable StringToNumber(Isolate* isolate);
|
2015-08-28 12:59:51 +00:00
|
|
|
static Callable ToString(Isolate* isolate);
|
2016-01-22 09:52:16 +00:00
|
|
|
static Callable ToName(Isolate* isolate);
|
2016-04-01 08:00:37 +00:00
|
|
|
static Callable ToInteger(Isolate* isolate);
|
2015-10-19 08:35:00 +00:00
|
|
|
static Callable ToLength(Isolate* isolate);
|
2015-07-31 12:25:28 +00:00
|
|
|
static Callable ToObject(Isolate* isolate);
|
2016-07-14 10:25:45 +00:00
|
|
|
static Callable NonPrimitiveToPrimitive(
|
|
|
|
Isolate* isolate, ToPrimitiveHint hint = ToPrimitiveHint::kDefault);
|
|
|
|
static Callable OrdinaryToPrimitive(Isolate* isolate,
|
|
|
|
OrdinaryToPrimitiveHint hint);
|
2015-10-19 11:59:24 +00:00
|
|
|
static Callable NumberToString(Isolate* isolate);
|
|
|
|
|
2015-12-11 09:11:26 +00:00
|
|
|
static Callable RegExpExec(Isolate* isolate);
|
2014-09-11 13:18:58 +00:00
|
|
|
|
2016-03-22 15:42:24 +00:00
|
|
|
static Callable Add(Isolate* isolate);
|
|
|
|
static Callable Subtract(Isolate* isolate);
|
2016-04-06 09:04:54 +00:00
|
|
|
static Callable Multiply(Isolate* isolate);
|
2016-04-08 14:53:04 +00:00
|
|
|
static Callable Divide(Isolate* isolate);
|
2016-04-11 13:54:14 +00:00
|
|
|
static Callable Modulus(Isolate* isolate);
|
2016-04-13 13:51:23 +00:00
|
|
|
static Callable ShiftRight(Isolate* isolate);
|
|
|
|
static Callable ShiftRightLogical(Isolate* isolate);
|
|
|
|
static Callable ShiftLeft(Isolate* isolate);
|
2016-03-23 13:44:32 +00:00
|
|
|
static Callable BitwiseAnd(Isolate* isolate);
|
|
|
|
static Callable BitwiseOr(Isolate* isolate);
|
|
|
|
static Callable BitwiseXor(Isolate* isolate);
|
2016-04-22 10:35:42 +00:00
|
|
|
static Callable Inc(Isolate* isolate);
|
|
|
|
static Callable Dec(Isolate* isolate);
|
2016-03-03 16:38:55 +00:00
|
|
|
static Callable LessThan(Isolate* isolate);
|
|
|
|
static Callable LessThanOrEqual(Isolate* isolate);
|
|
|
|
static Callable GreaterThan(Isolate* isolate);
|
|
|
|
static Callable GreaterThanOrEqual(Isolate* isolate);
|
2016-03-16 09:36:52 +00:00
|
|
|
static Callable Equal(Isolate* isolate);
|
|
|
|
static Callable NotEqual(Isolate* isolate);
|
2016-03-02 11:46:57 +00:00
|
|
|
static Callable StrictEqual(Isolate* isolate);
|
2016-03-02 12:34:36 +00:00
|
|
|
static Callable StrictNotEqual(Isolate* isolate);
|
2016-03-02 11:46:57 +00:00
|
|
|
|
2014-09-11 13:18:58 +00:00
|
|
|
static Callable StringAdd(Isolate* isolate, StringAddFlags flags,
|
|
|
|
PretenureFlag pretenure_flag);
|
2016-03-04 09:38:31 +00:00
|
|
|
static Callable StringCompare(Isolate* isolate, Token::Value token);
|
2016-03-03 10:10:30 +00:00
|
|
|
static Callable StringEqual(Isolate* isolate);
|
|
|
|
static Callable StringNotEqual(Isolate* isolate);
|
2016-03-04 09:38:31 +00:00
|
|
|
static Callable StringLessThan(Isolate* isolate);
|
|
|
|
static Callable StringLessThanOrEqual(Isolate* isolate);
|
|
|
|
static Callable StringGreaterThan(Isolate* isolate);
|
|
|
|
static Callable StringGreaterThanOrEqual(Isolate* isolate);
|
2015-12-11 09:11:26 +00:00
|
|
|
static Callable SubString(Isolate* isolate);
|
2014-09-11 13:18:58 +00:00
|
|
|
|
2015-05-06 13:31:00 +00:00
|
|
|
static Callable Typeof(Isolate* isolate);
|
|
|
|
|
2015-11-25 09:22:39 +00:00
|
|
|
static Callable FastCloneRegExp(Isolate* isolate);
|
2015-04-21 15:43:31 +00:00
|
|
|
static Callable FastCloneShallowArray(Isolate* isolate);
|
|
|
|
static Callable FastCloneShallowObject(Isolate* isolate, int length);
|
|
|
|
|
2016-08-01 19:26:46 +00:00
|
|
|
static Callable FastNewFunctionContext(Isolate* isolate);
|
2016-06-30 09:42:29 +00:00
|
|
|
static Callable FastNewClosure(Isolate* isolate);
|
2016-02-19 07:12:18 +00:00
|
|
|
static Callable FastNewObject(Isolate* isolate);
|
2016-05-11 15:06:40 +00:00
|
|
|
static Callable FastNewRestParameter(Isolate* isolate,
|
|
|
|
bool skip_stub_frame = false);
|
|
|
|
static Callable FastNewSloppyArguments(Isolate* isolate,
|
|
|
|
bool skip_stub_frame = false);
|
|
|
|
static Callable FastNewStrictArguments(Isolate* isolate,
|
|
|
|
bool skip_stub_frame = false);
|
2015-04-27 09:08:20 +00:00
|
|
|
|
2016-08-08 08:43:48 +00:00
|
|
|
static Callable CopyFastSmiOrObjectElements(Isolate* isolate);
|
|
|
|
static Callable GrowFastDoubleElements(Isolate* isolate);
|
|
|
|
static Callable GrowFastSmiOrObjectElements(Isolate* isolate);
|
2016-08-05 15:28:52 +00:00
|
|
|
|
2016-12-08 08:28:13 +00:00
|
|
|
static Callable NewUnmappedArgumentsElements(Isolate* isolate);
|
|
|
|
static Callable NewRestParameterElements(Isolate* isolate);
|
|
|
|
|
2014-11-04 12:58:17 +00:00
|
|
|
static Callable AllocateHeapNumber(Isolate* isolate);
|
2016-03-21 15:45:32 +00:00
|
|
|
#define SIMD128_ALLOC(TYPE, Type, type, lane_count, lane_type) \
|
|
|
|
static Callable Allocate##Type(Isolate* isolate);
|
|
|
|
SIMD128_TYPES(SIMD128_ALLOC)
|
|
|
|
#undef SIMD128_ALLOC
|
2014-11-04 12:58:17 +00:00
|
|
|
|
2015-11-04 11:53:08 +00:00
|
|
|
static Callable ArgumentAdaptor(Isolate* isolate);
|
2015-11-09 08:47:59 +00:00
|
|
|
static Callable Call(Isolate* isolate,
|
2016-03-07 14:33:54 +00:00
|
|
|
ConvertReceiverMode mode = ConvertReceiverMode::kAny,
|
|
|
|
TailCallMode tail_call_mode = TailCallMode::kDisallow);
|
2015-11-09 08:47:59 +00:00
|
|
|
static Callable CallFunction(
|
|
|
|
Isolate* isolate, ConvertReceiverMode mode = ConvertReceiverMode::kAny);
|
2015-11-23 10:34:04 +00:00
|
|
|
static Callable Construct(Isolate* isolate);
|
2015-12-10 06:03:37 +00:00
|
|
|
static Callable ConstructFunction(Isolate* isolate);
|
2016-05-03 11:11:27 +00:00
|
|
|
static Callable HasProperty(Isolate* isolate);
|
2016-07-21 09:33:26 +00:00
|
|
|
static Callable ForInFilter(Isolate* isolate);
|
2015-11-04 11:53:08 +00:00
|
|
|
|
2016-07-13 07:58:40 +00:00
|
|
|
static Callable InterpreterPushArgsAndCall(
|
|
|
|
Isolate* isolate, TailCallMode tail_call_mode,
|
|
|
|
CallableType function_type = CallableType::kAny);
|
2016-09-02 08:26:36 +00:00
|
|
|
static Callable InterpreterPushArgsAndConstruct(
|
|
|
|
Isolate* isolate, CallableType function_type = CallableType::kAny);
|
2016-09-08 14:49:24 +00:00
|
|
|
static Callable InterpreterPushArgsAndConstructArray(Isolate* isolate);
|
2016-01-08 15:15:52 +00:00
|
|
|
static Callable InterpreterCEntry(Isolate* isolate, int result_size = 1);
|
2016-07-26 14:31:10 +00:00
|
|
|
static Callable InterpreterOnStackReplacement(Isolate* isolate);
|
2016-11-29 16:57:58 +00:00
|
|
|
|
|
|
|
static Callable ArrayPush(Isolate* isolate);
|
2016-12-01 21:15:08 +00:00
|
|
|
static Callable FunctionPrototypeBind(Isolate* isolate);
|
2016-12-13 23:54:04 +00:00
|
|
|
static Callable PromiseHandleReject(Isolate* isolate);
|
2014-09-11 13:18:58 +00:00
|
|
|
};
|
2014-11-04 12:58:17 +00:00
|
|
|
|
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|
|
|
|
|
2014-09-11 13:18:58 +00:00
|
|
|
#endif // V8_CODE_FACTORY_H_
|