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.
|
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-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.
|
2016-07-14 10:25:45 +00:00
|
|
|
static Callable GetProperty(Isolate* isolate);
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
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);
|
2015-05-06 13:31:00 +00:00
|
|
|
|
2016-12-29 13:02:08 +00:00
|
|
|
static Callable FastCloneShallowArray(Isolate* isolate,
|
|
|
|
AllocationSiteMode allocation_mode);
|
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-12-08 08:28:13 +00:00
|
|
|
|
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-06-08 18:31:59 +00:00
|
|
|
static Callable CallVarargs(Isolate* isolate);
|
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);
|
2017-06-08 18:31:59 +00:00
|
|
|
static Callable ConstructVarargs(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);
|
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_
|