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"
|
2017-03-16 14:22:12 +00:00
|
|
|
#include "src/callable.h"
|
2014-09-11 13:18:58 +00:00
|
|
|
#include "src/codegen.h"
|
|
|
|
#include "src/globals.h"
|
|
|
|
#include "src/interface-descriptors.h"
|
|
|
|
|
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
|
|
|
|
2016-10-17 10:01:42 +00:00
|
|
|
class V8_EXPORT_PRIVATE CodeFactory final {
|
2014-09-11 13:18:58 +00:00
|
|
|
public:
|
2016-12-15 17:18:42 +00:00
|
|
|
// CEntryStub has var-args semantics (all the arguments are passed on the
|
|
|
|
// stack and the arguments count is passed via register) which currently
|
|
|
|
// can't be expressed in CallInterfaceDescriptor. Therefore only the code
|
|
|
|
// is exported here.
|
|
|
|
static Handle<Code> RuntimeCEntry(Isolate* isolate, int result_size = 1);
|
|
|
|
|
2014-09-11 13:18:58 +00:00
|
|
|
// Initial states for ICs.
|
2016-06-14 13:20:42 +00:00
|
|
|
static Callable LoadIC(Isolate* isolate);
|
2017-02-28 11:04:04 +00:00
|
|
|
static Callable LoadIC_Uninitialized(Isolate* isolate);
|
2016-06-14 13:20:42 +00:00
|
|
|
static Callable LoadICInOptimizedCode(Isolate* isolate);
|
2017-03-07 10:21:33 +00:00
|
|
|
static Callable LoadICInOptimizedCode_Noninlined(Isolate* isolate);
|
2017-01-19 18:39:07 +00:00
|
|
|
static Callable LoadICProtoArray(Isolate* isolate, bool throw_if_nonexistent);
|
2016-06-14 13:20:42 +00:00
|
|
|
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);
|
2017-02-02 06:54:27 +00:00
|
|
|
static Callable CallICTrampoline(
|
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);
|
2017-03-23 16:46:53 +00:00
|
|
|
static Callable StoreGlobalIC(Isolate* isolate, LanguageMode mode);
|
|
|
|
static Callable StoreGlobalICInOptimizedCode(Isolate* isolate,
|
|
|
|
LanguageMode mode);
|
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);
|
2017-03-14 16:59:22 +00:00
|
|
|
static Callable StoreIC_Uninitialized(Isolate* isolate, LanguageMode mode);
|
2017-02-17 15:15:07 +00:00
|
|
|
static Callable StoreOwnIC(Isolate* isolate);
|
|
|
|
static Callable StoreOwnICInOptimizedCode(Isolate* isolate);
|
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);
|
|
|
|
|
2017-01-27 07:31:03 +00:00
|
|
|
static Callable FrameDropperTrampoline(Isolate* isolate);
|
|
|
|
static Callable HandleDebuggerStatement(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);
|
|
|
|
|
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);
|
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);
|
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);
|
|
|
|
|
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-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);
|
2016-03-02 11:46:57 +00:00
|
|
|
static Callable StrictEqual(Isolate* isolate);
|
|
|
|
|
2017-03-21 06:36:11 +00:00
|
|
|
static Callable StringAdd(Isolate* isolate,
|
|
|
|
StringAddFlags flags = STRING_ADD_CHECK_NONE,
|
|
|
|
PretenureFlag pretenure_flag = NOT_TENURED);
|
2016-03-04 09:38:31 +00:00
|
|
|
static Callable StringCompare(Isolate* isolate, Token::Value token);
|
2015-12-11 09:11:26 +00:00
|
|
|
static Callable SubString(Isolate* isolate);
|
2017-01-26 12:46:44 +00:00
|
|
|
static Callable StringIndexOf(Isolate* isolate);
|
2014-09-11 13:18:58 +00:00
|
|
|
|
2017-01-20 07:01:52 +00:00
|
|
|
static Callable ClassOf(Isolate* isolate);
|
2016-12-19 10:12:22 +00:00
|
|
|
static Callable GetSuperConstructor(Isolate* isolate);
|
2015-05-06 13:31:00 +00:00
|
|
|
|
2015-11-25 09:22:39 +00:00
|
|
|
static Callable FastCloneRegExp(Isolate* isolate);
|
2016-12-29 13:02:08 +00:00
|
|
|
static Callable FastCloneShallowArray(Isolate* isolate,
|
|
|
|
AllocationSiteMode allocation_mode);
|
2017-05-18 07:29:45 +00:00
|
|
|
static Callable FastCloneShallowObject(Isolate* isolate);
|
2015-04-21 15:43:31 +00:00
|
|
|
|
2016-12-20 16:23:19 +00:00
|
|
|
static Callable FastNewFunctionContext(Isolate* isolate,
|
|
|
|
ScopeType scope_type);
|
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);
|
2017-02-07 16:02:44 +00:00
|
|
|
static Callable FastNewRestParameter(Isolate* isolate);
|
|
|
|
static Callable FastNewSloppyArguments(Isolate* isolate);
|
|
|
|
static Callable FastNewStrictArguments(Isolate* isolate);
|
2015-04-27 09:08:20 +00:00
|
|
|
|
2017-02-08 14:26:56 +00:00
|
|
|
static Callable ForInPrepare(Isolate* isolate);
|
|
|
|
static Callable ForInNext(Isolate* isolate);
|
|
|
|
|
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);
|
|
|
|
|
2014-11-04 12:58:17 +00:00
|
|
|
static Callable AllocateHeapNumber(Isolate* isolate);
|
|
|
|
|
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);
|
2017-01-24 14:37:01 +00:00
|
|
|
static Callable CallWithSpread(Isolate* isolate);
|
2015-11-09 08:47:59 +00:00
|
|
|
static Callable CallFunction(
|
2017-02-02 13:29:33 +00:00
|
|
|
Isolate* isolate, ConvertReceiverMode mode = ConvertReceiverMode::kAny,
|
|
|
|
TailCallMode tail_call_mode = TailCallMode::kDisallow);
|
2017-01-26 09:29:56 +00:00
|
|
|
static Callable CallForwardVarargs(Isolate* isolate);
|
|
|
|
static Callable CallFunctionForwardVarargs(Isolate* isolate);
|
2015-11-23 10:34:04 +00:00
|
|
|
static Callable Construct(Isolate* isolate);
|
2017-01-18 10:34:24 +00:00
|
|
|
static Callable ConstructWithSpread(Isolate* isolate);
|
2015-12-10 06:03:37 +00:00
|
|
|
static Callable ConstructFunction(Isolate* isolate);
|
[turbofan] Avoid allocating rest parameters for spread calls.
We already had an optimization to turn Function.prototype.apply with
arguments object, i.e.
function foo() { return bar.apply(this, arguments); }
into a special operator JSCallForwardVarargs, which avoids the
allocation and deconstruction of the arguments object, but just passes
along the incoming parameters. We can do the same for rest parameters
and spread calls/constructs, i.e.
class A extends B {
constructor(...args) { super(...args); }
}
or
function foo(...args) { return bar(1, 2, 3, ...args); }
where we basically pass along the parameters (plus maybe additional
statically known parameters).
For this, we introduce a new JSConstructForwardVarargs operator and
generalize the CallForwardVarargs builtins that are backing this.
BUG=v8:6407,v8:6278,v8:6344
R=jarin@chromium.org
Review-Url: https://codereview.chromium.org/2890023004
Cr-Commit-Position: refs/heads/master@{#45388}
2017-05-18 07:32:22 +00:00
|
|
|
static Callable ConstructForwardVarargs(Isolate* isolate);
|
|
|
|
static Callable ConstructFunctionForwardVarargs(Isolate* isolate);
|
2017-01-11 11:34:02 +00:00
|
|
|
static Callable CreateIterResultObject(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
|
|
|
|
2017-04-11 14:20:30 +00:00
|
|
|
static Callable InterpreterPushArgsThenCall(Isolate* isolate,
|
|
|
|
ConvertReceiverMode receiver_mode,
|
|
|
|
TailCallMode tail_call_mode,
|
|
|
|
InterpreterPushArgsMode mode);
|
|
|
|
static Callable InterpreterPushArgsThenConstruct(
|
|
|
|
Isolate* isolate, InterpreterPushArgsMode mode);
|
|
|
|
static Callable InterpreterPushArgsThenConstructArray(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
|
|
|
|
2017-02-02 13:29:33 +00:00
|
|
|
static Callable ArrayConstructor(Isolate* isolate);
|
2017-05-05 12:11:36 +00:00
|
|
|
static Callable ArrayPop(Isolate* isolate);
|
2016-11-29 16:57:58 +00:00
|
|
|
static Callable ArrayPush(Isolate* isolate);
|
2017-05-17 14:39:34 +00:00
|
|
|
static Callable ArrayShift(Isolate* isolate);
|
2016-12-01 21:15:08 +00:00
|
|
|
static Callable FunctionPrototypeBind(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_
|