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);
|
|
|
|
|
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);
|
|
|
|
|
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-12-22 06:49:07 +00:00
|
|
|
static Callable StringCharAt(Isolate* isolate);
|
2016-12-22 07:11:22 +00:00
|
|
|
static Callable StringCharCodeAt(Isolate* isolate);
|
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);
|
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);
|
2017-01-26 12:46:44 +00:00
|
|
|
static Callable StringIndexOf(Isolate* isolate);
|
2014-09-11 13:18:58 +00:00
|
|
|
|
2017-02-03 10:31:29 +00:00
|
|
|
static Callable RegExpReplace(Isolate* isolate);
|
|
|
|
static Callable RegExpSplit(Isolate* isolate);
|
|
|
|
|
2017-01-20 07:01:52 +00:00
|
|
|
static Callable ClassOf(Isolate* isolate);
|
2015-05-06 13:31:00 +00:00
|
|
|
static Callable Typeof(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);
|
2015-04-21 15:43:31 +00:00
|
|
|
static Callable FastCloneShallowObject(Isolate* isolate, int length);
|
|
|
|
|
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);
|
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);
|
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);
|
[async-iteration] implement AsyncGenerator
- Introduce new struct AsyncGeneratorRequest, which holds
information pertinent to resuming execution of an
AsyncGenerator, such as the Promise associated with the async
generator request. It is intended to be used as a singly
linked list, and holds a pointer to the next item in te queue.
- Introduce JSAsyncGeneratorObject (subclass of
JSGeneratorObject), which includes several new internal fields
(`queue` which contains a singly linked list of
AsyncGeneratorRequest objects, and `await_input` which
contains the sent value from an Await expression (This is
necessary to prevent function.sent (used by yield*) from
having the sent value observably overwritten during
execution).
- Modify SuspendGenerator to accept a set of Flags, which
indicate whether the suspend is for a Yield or Await, and
whether it takes place on an async generator or ES6
generator.
- Introduce interpreter intrinsics and TF intrinsic lowering for
accessing the await input of an async generator
- Modify the JSGeneratorStore operator to understand whether or
not it's suspending for a normal yield, or an AsyncGenerator
Await. This ensures appropriate registers are stored.
- Add versions of ResumeGeneratorTrampoline which store the
input value in a different field depending on wether it's an
AsyncGenerator Await resume, or an ordinary resume. Also modifies
whether debug code will assert that the generator object is a
JSGeneratorObject or a JSAsyncGeneratorObject depending on the
resume type.
BUG=v8:5855
R=bmeurer@chromium.org, rmcilroy@chromium.org, jgruber@chromium.org,
littledan@chromium.org, neis@chromium.org
TBR=marja@chromium.org
Change-Id: I9d58df1d344465fc937fe7eed322424204497187
Reviewed-on: https://chromium-review.googlesource.com/446961
Commit-Queue: Caitlin Potter <caitp@igalia.com>
Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
Reviewed-by: Hannes Payer <hpayer@chromium.org>
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#44240}
2017-03-29 13:41:45 +00:00
|
|
|
|
|
|
|
static Callable AsyncGeneratorResolve(Isolate* isolate);
|
|
|
|
static Callable AsyncGeneratorReject(Isolate* isolate);
|
|
|
|
static Callable AsyncGeneratorResumeNext(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_
|