2014-09-11 13:18:58 +00:00
|
|
|
// Copyright 2014 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.
|
|
|
|
|
2015-08-14 09:41:32 +00:00
|
|
|
#include "src/code-factory.h"
|
2014-09-11 13:18:58 +00:00
|
|
|
|
|
|
|
#include "src/bootstrapper.h"
|
|
|
|
#include "src/ic/ic.h"
|
2017-02-23 11:46:29 +00:00
|
|
|
#include "src/objects-inl.h"
|
2014-09-11 13:18:58 +00:00
|
|
|
|
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
|
|
|
|
2016-07-27 12:00:04 +00:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
// TODO(ishell): make it (const Stub& stub) once CodeStub::GetCode() is const.
|
|
|
|
template <typename Stub>
|
|
|
|
Callable make_callable(Stub& stub) {
|
|
|
|
typedef typename Stub::Descriptor Descriptor;
|
|
|
|
return Callable(stub.GetCode(), Descriptor(stub.isolate()));
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|
2015-03-02 13:36:38 +00:00
|
|
|
|
2016-12-15 17:18:42 +00:00
|
|
|
// static
|
|
|
|
Handle<Code> CodeFactory::RuntimeCEntry(Isolate* isolate, int result_size) {
|
|
|
|
CEntryStub stub(isolate, result_size);
|
|
|
|
return stub.GetCode();
|
|
|
|
}
|
|
|
|
|
2014-09-11 13:18:58 +00:00
|
|
|
// static
|
2016-06-14 13:20:42 +00:00
|
|
|
Callable CodeFactory::LoadIC(Isolate* isolate) {
|
2016-12-30 10:31:01 +00:00
|
|
|
return Callable(isolate->builtins()->LoadICTrampoline(),
|
|
|
|
LoadDescriptor(isolate));
|
2014-09-11 13:18:58 +00:00
|
|
|
}
|
|
|
|
|
2017-01-19 18:39:07 +00:00
|
|
|
// static
|
|
|
|
Callable CodeFactory::LoadICProtoArray(Isolate* isolate,
|
|
|
|
bool throw_if_nonexistent) {
|
|
|
|
return Callable(
|
|
|
|
throw_if_nonexistent
|
|
|
|
? isolate->builtins()->LoadICProtoArrayThrowIfNonexistent()
|
|
|
|
: isolate->builtins()->LoadICProtoArray(),
|
|
|
|
LoadICProtoArrayDescriptor(isolate));
|
|
|
|
}
|
|
|
|
|
2016-04-19 12:11:05 +00:00
|
|
|
// static
|
|
|
|
Callable CodeFactory::ApiGetter(Isolate* isolate) {
|
|
|
|
CallApiGetterStub stub(isolate);
|
2016-07-27 12:00:04 +00:00
|
|
|
return make_callable(stub);
|
2016-04-19 12:11:05 +00:00
|
|
|
}
|
2014-09-11 13:18:58 +00:00
|
|
|
|
2014-10-10 09:49:43 +00:00
|
|
|
// static
|
2016-06-14 13:20:42 +00:00
|
|
|
Callable CodeFactory::LoadICInOptimizedCode(Isolate* isolate) {
|
2016-12-30 10:31:01 +00:00
|
|
|
return Callable(isolate->builtins()->LoadIC(),
|
|
|
|
LoadWithVectorDescriptor(isolate));
|
2014-10-10 09:49:43 +00:00
|
|
|
}
|
|
|
|
|
2017-03-07 10:21:33 +00:00
|
|
|
// static
|
|
|
|
Callable CodeFactory::LoadICInOptimizedCode_Noninlined(Isolate* isolate) {
|
|
|
|
return Callable(isolate->builtins()->LoadIC_Noninlined(),
|
|
|
|
LoadWithVectorDescriptor(isolate));
|
|
|
|
}
|
|
|
|
|
2016-06-14 13:20:42 +00:00
|
|
|
// static
|
|
|
|
Callable CodeFactory::LoadGlobalIC(Isolate* isolate, TypeofMode typeof_mode) {
|
2016-12-30 13:37:08 +00:00
|
|
|
return Callable(
|
|
|
|
typeof_mode == NOT_INSIDE_TYPEOF
|
|
|
|
? isolate->builtins()->LoadGlobalICTrampoline()
|
|
|
|
: isolate->builtins()->LoadGlobalICInsideTypeofTrampoline(),
|
|
|
|
LoadGlobalDescriptor(isolate));
|
2016-06-14 13:20:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
Callable CodeFactory::LoadGlobalICInOptimizedCode(Isolate* isolate,
|
|
|
|
TypeofMode typeof_mode) {
|
2016-12-30 13:37:08 +00:00
|
|
|
return Callable(typeof_mode == NOT_INSIDE_TYPEOF
|
|
|
|
? isolate->builtins()->LoadGlobalIC()
|
|
|
|
: isolate->builtins()->LoadGlobalICInsideTypeof(),
|
|
|
|
LoadGlobalWithVectorDescriptor(isolate));
|
2016-06-14 13:20:42 +00:00
|
|
|
}
|
2014-10-10 09:49:43 +00:00
|
|
|
|
2014-09-11 13:18:58 +00:00
|
|
|
// static
|
2016-02-17 10:30:10 +00:00
|
|
|
Callable CodeFactory::KeyedLoadIC(Isolate* isolate) {
|
2016-12-30 10:31:01 +00:00
|
|
|
return Callable(isolate->builtins()->KeyedLoadICTrampoline(),
|
|
|
|
LoadDescriptor(isolate));
|
2014-09-11 13:18:58 +00:00
|
|
|
}
|
|
|
|
|
2014-10-10 09:49:43 +00:00
|
|
|
// static
|
2016-05-30 19:26:02 +00:00
|
|
|
Callable CodeFactory::KeyedLoadICInOptimizedCode(Isolate* isolate) {
|
2016-12-30 10:31:01 +00:00
|
|
|
return Callable(isolate->builtins()->KeyedLoadIC(),
|
|
|
|
LoadWithVectorDescriptor(isolate));
|
2014-10-10 09:49:43 +00:00
|
|
|
}
|
|
|
|
|
2015-01-27 11:23:51 +00:00
|
|
|
// static
|
2016-10-12 09:25:55 +00:00
|
|
|
Callable CodeFactory::CallIC(Isolate* isolate, ConvertReceiverMode mode,
|
2016-01-26 11:07:15 +00:00
|
|
|
TailCallMode tail_call_mode) {
|
2017-02-02 07:44:18 +00:00
|
|
|
CallICStub stub(isolate, mode, tail_call_mode);
|
2016-07-27 12:00:04 +00:00
|
|
|
return make_callable(stub);
|
2015-01-27 11:23:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2017-02-02 06:54:27 +00:00
|
|
|
Callable CodeFactory::CallICTrampoline(Isolate* isolate,
|
|
|
|
ConvertReceiverMode mode,
|
|
|
|
TailCallMode tail_call_mode) {
|
2017-02-02 07:44:18 +00:00
|
|
|
CallICTrampolineStub stub(isolate, mode, tail_call_mode);
|
2016-07-27 12:00:04 +00:00
|
|
|
return make_callable(stub);
|
2015-01-27 11:23:51 +00:00
|
|
|
}
|
|
|
|
|
2014-09-11 13:18:58 +00:00
|
|
|
// static
|
2015-02-04 09:34:05 +00:00
|
|
|
Callable CodeFactory::StoreIC(Isolate* isolate, LanguageMode language_mode) {
|
2016-12-30 10:31:01 +00:00
|
|
|
return Callable(language_mode == STRICT
|
|
|
|
? isolate->builtins()->StoreICStrictTrampoline()
|
|
|
|
: isolate->builtins()->StoreICTrampoline(),
|
|
|
|
StoreDescriptor(isolate));
|
2015-06-26 07:53:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2016-05-30 19:26:02 +00:00
|
|
|
Callable CodeFactory::StoreICInOptimizedCode(Isolate* isolate,
|
|
|
|
LanguageMode language_mode) {
|
2016-12-30 10:31:01 +00:00
|
|
|
return Callable(language_mode == STRICT ? isolate->builtins()->StoreICStrict()
|
|
|
|
: isolate->builtins()->StoreIC(),
|
|
|
|
StoreWithVectorDescriptor(isolate));
|
2014-09-11 13:18:58 +00:00
|
|
|
}
|
|
|
|
|
2017-03-14 16:59:22 +00:00
|
|
|
// static
|
|
|
|
Callable CodeFactory::StoreIC_Uninitialized(Isolate* isolate,
|
|
|
|
LanguageMode language_mode) {
|
|
|
|
return Callable(language_mode == STRICT
|
|
|
|
? isolate->builtins()->StoreICStrict_Uninitialized()
|
|
|
|
: isolate->builtins()->StoreIC_Uninitialized(),
|
|
|
|
StoreWithVectorDescriptor(isolate));
|
|
|
|
}
|
|
|
|
|
2017-02-17 15:15:07 +00:00
|
|
|
Callable CodeFactory::StoreOwnIC(Isolate* isolate) {
|
|
|
|
// TODO(ishell): Currently we use StoreOwnIC only for storing properties that
|
|
|
|
// already exist in the boilerplate therefore we can use StoreIC.
|
|
|
|
return Callable(isolate->builtins()->StoreICStrictTrampoline(),
|
|
|
|
StoreDescriptor(isolate));
|
|
|
|
}
|
|
|
|
|
|
|
|
Callable CodeFactory::StoreOwnICInOptimizedCode(Isolate* isolate) {
|
|
|
|
// TODO(ishell): Currently we use StoreOwnIC only for storing properties that
|
|
|
|
// already exist in the boilerplate therefore we can use StoreIC.
|
|
|
|
return Callable(isolate->builtins()->StoreICStrict(),
|
|
|
|
StoreWithVectorDescriptor(isolate));
|
|
|
|
}
|
|
|
|
|
2014-09-11 13:18:58 +00:00
|
|
|
// static
|
2015-02-04 09:34:05 +00:00
|
|
|
Callable CodeFactory::KeyedStoreIC(Isolate* isolate,
|
|
|
|
LanguageMode language_mode) {
|
2016-12-30 10:31:01 +00:00
|
|
|
return Callable(language_mode == STRICT
|
|
|
|
? isolate->builtins()->KeyedStoreICStrictTrampoline()
|
|
|
|
: isolate->builtins()->KeyedStoreICTrampoline(),
|
|
|
|
StoreDescriptor(isolate));
|
2015-02-25 19:32:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2016-05-30 19:26:02 +00:00
|
|
|
Callable CodeFactory::KeyedStoreICInOptimizedCode(Isolate* isolate,
|
|
|
|
LanguageMode language_mode) {
|
2016-12-30 10:31:01 +00:00
|
|
|
return Callable(language_mode == STRICT
|
|
|
|
? isolate->builtins()->KeyedStoreICStrict()
|
|
|
|
: isolate->builtins()->KeyedStoreIC(),
|
|
|
|
StoreWithVectorDescriptor(isolate));
|
2014-09-11 13:18:58 +00:00
|
|
|
}
|
|
|
|
|
2016-10-19 10:11:25 +00:00
|
|
|
// static
|
|
|
|
Callable CodeFactory::KeyedStoreIC_Megamorphic(Isolate* isolate,
|
|
|
|
LanguageMode language_mode) {
|
2017-01-19 18:39:07 +00:00
|
|
|
return Callable(language_mode == STRICT
|
|
|
|
? isolate->builtins()->KeyedStoreIC_Megamorphic_Strict()
|
|
|
|
: isolate->builtins()->KeyedStoreIC_Megamorphic(),
|
|
|
|
StoreWithVectorDescriptor(isolate));
|
2016-10-19 10:11:25 +00:00
|
|
|
}
|
|
|
|
|
2014-09-11 13:18:58 +00:00
|
|
|
// static
|
2016-02-16 13:54:51 +00:00
|
|
|
Callable CodeFactory::CompareIC(Isolate* isolate, Token::Value op) {
|
2016-07-27 12:00:04 +00:00
|
|
|
CompareICStub stub(isolate, op);
|
|
|
|
return make_callable(stub);
|
2014-09-11 13:18:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2016-02-16 13:54:51 +00:00
|
|
|
Callable CodeFactory::BinaryOpIC(Isolate* isolate, Token::Value op) {
|
|
|
|
BinaryOpICStub stub(isolate, op);
|
2016-07-27 12:00:04 +00:00
|
|
|
return make_callable(stub);
|
2015-07-13 09:18:44 +00:00
|
|
|
}
|
|
|
|
|
2016-07-14 10:25:45 +00:00
|
|
|
// static
|
|
|
|
Callable CodeFactory::GetProperty(Isolate* isolate) {
|
|
|
|
GetPropertyStub stub(isolate);
|
2016-07-27 12:00:04 +00:00
|
|
|
return make_callable(stub);
|
2016-07-14 10:25:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
Callable CodeFactory::NonPrimitiveToPrimitive(Isolate* isolate,
|
|
|
|
ToPrimitiveHint hint) {
|
|
|
|
return Callable(isolate->builtins()->NonPrimitiveToPrimitive(hint),
|
|
|
|
TypeConversionDescriptor(isolate));
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
Callable CodeFactory::OrdinaryToPrimitive(Isolate* isolate,
|
|
|
|
OrdinaryToPrimitiveHint hint) {
|
|
|
|
return Callable(isolate->builtins()->OrdinaryToPrimitive(hint),
|
|
|
|
TypeConversionDescriptor(isolate));
|
|
|
|
}
|
2015-07-31 12:25:28 +00:00
|
|
|
|
2015-10-19 11:59:24 +00:00
|
|
|
// static
|
|
|
|
Callable CodeFactory::NumberToString(Isolate* isolate) {
|
|
|
|
NumberToStringStub stub(isolate);
|
2016-07-27 12:00:04 +00:00
|
|
|
return make_callable(stub);
|
2015-10-19 11:59:24 +00:00
|
|
|
}
|
|
|
|
|
2015-12-11 09:11:26 +00:00
|
|
|
// static
|
|
|
|
Callable CodeFactory::RegExpExec(Isolate* isolate) {
|
|
|
|
RegExpExecStub stub(isolate);
|
|
|
|
return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor());
|
|
|
|
}
|
|
|
|
|
2016-11-07 21:26:18 +00:00
|
|
|
// static
|
|
|
|
Callable CodeFactory::StringFromCharCode(Isolate* isolate) {
|
|
|
|
Handle<Code> code(isolate->builtins()->StringFromCharCode());
|
|
|
|
return Callable(code, BuiltinDescriptor(isolate));
|
|
|
|
}
|
|
|
|
|
2017-02-08 14:26:56 +00:00
|
|
|
#define DECLARE_TFS(Name, Kind, Extra, InterfaceDescriptor, result_size) \
|
2016-10-06 15:46:11 +00:00
|
|
|
typedef InterfaceDescriptor##Descriptor Name##Descriptor;
|
|
|
|
BUILTIN_LIST(IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN, DECLARE_TFS,
|
|
|
|
IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN)
|
|
|
|
#undef DECLARE_TFS
|
2016-03-23 13:44:32 +00:00
|
|
|
|
2016-10-06 15:46:11 +00:00
|
|
|
#define TFS_BUILTIN(Name) \
|
|
|
|
Callable CodeFactory::Name(Isolate* isolate) { \
|
|
|
|
Handle<Code> code(isolate->builtins()->Name()); \
|
|
|
|
return Callable(code, Name##Descriptor(isolate)); \
|
|
|
|
}
|
2016-03-23 13:44:32 +00:00
|
|
|
|
2016-10-06 15:46:11 +00:00
|
|
|
TFS_BUILTIN(ToString)
|
|
|
|
TFS_BUILTIN(Add)
|
|
|
|
TFS_BUILTIN(Subtract)
|
|
|
|
TFS_BUILTIN(Multiply)
|
|
|
|
TFS_BUILTIN(Divide)
|
|
|
|
TFS_BUILTIN(Modulus)
|
|
|
|
TFS_BUILTIN(BitwiseAnd)
|
|
|
|
TFS_BUILTIN(BitwiseOr)
|
|
|
|
TFS_BUILTIN(BitwiseXor)
|
|
|
|
TFS_BUILTIN(ShiftLeft)
|
|
|
|
TFS_BUILTIN(ShiftRight)
|
|
|
|
TFS_BUILTIN(ShiftRightLogical)
|
|
|
|
TFS_BUILTIN(LessThan)
|
|
|
|
TFS_BUILTIN(LessThanOrEqual)
|
|
|
|
TFS_BUILTIN(GreaterThan)
|
|
|
|
TFS_BUILTIN(GreaterThanOrEqual)
|
|
|
|
TFS_BUILTIN(Equal)
|
|
|
|
TFS_BUILTIN(StrictEqual)
|
2017-01-11 11:34:02 +00:00
|
|
|
TFS_BUILTIN(CreateIterResultObject)
|
2016-10-06 15:46:11 +00:00
|
|
|
TFS_BUILTIN(HasProperty)
|
2017-01-19 18:39:07 +00:00
|
|
|
TFS_BUILTIN(NonNumberToNumber)
|
|
|
|
TFS_BUILTIN(StringToNumber)
|
|
|
|
TFS_BUILTIN(ToBoolean)
|
2016-10-06 15:46:11 +00:00
|
|
|
TFS_BUILTIN(ToInteger)
|
|
|
|
TFS_BUILTIN(ToLength)
|
2017-01-19 18:39:07 +00:00
|
|
|
TFS_BUILTIN(ToName)
|
|
|
|
TFS_BUILTIN(ToNumber)
|
2016-10-06 15:46:11 +00:00
|
|
|
TFS_BUILTIN(ToObject)
|
2017-01-20 07:01:52 +00:00
|
|
|
TFS_BUILTIN(ClassOf)
|
2016-10-06 15:46:11 +00:00
|
|
|
TFS_BUILTIN(Typeof)
|
|
|
|
TFS_BUILTIN(InstanceOf)
|
2016-11-18 06:30:57 +00:00
|
|
|
TFS_BUILTIN(OrdinaryHasInstance)
|
2017-01-19 18:39:07 +00:00
|
|
|
TFS_BUILTIN(CopyFastSmiOrObjectElements)
|
|
|
|
TFS_BUILTIN(GrowFastDoubleElements)
|
|
|
|
TFS_BUILTIN(GrowFastSmiOrObjectElements)
|
2016-12-08 08:28:13 +00:00
|
|
|
TFS_BUILTIN(NewUnmappedArgumentsElements)
|
2017-01-19 18:39:07 +00:00
|
|
|
TFS_BUILTIN(FastCloneRegExp)
|
|
|
|
TFS_BUILTIN(FastNewClosure)
|
|
|
|
TFS_BUILTIN(FastNewObject)
|
|
|
|
TFS_BUILTIN(ForInFilter)
|
2016-12-19 10:12:22 +00:00
|
|
|
TFS_BUILTIN(GetSuperConstructor)
|
2017-02-28 11:04:04 +00:00
|
|
|
TFS_BUILTIN(LoadIC_Uninitialized)
|
2017-01-19 18:39:07 +00:00
|
|
|
TFS_BUILTIN(KeyedLoadIC_Megamorphic)
|
|
|
|
TFS_BUILTIN(PromiseHandleReject)
|
2017-02-03 10:31:29 +00:00
|
|
|
TFS_BUILTIN(RegExpReplace)
|
|
|
|
TFS_BUILTIN(RegExpSplit)
|
2016-12-22 06:49:07 +00:00
|
|
|
TFS_BUILTIN(StringCharAt)
|
2016-12-22 07:11:22 +00:00
|
|
|
TFS_BUILTIN(StringCharCodeAt)
|
2017-01-19 18:39:07 +00:00
|
|
|
TFS_BUILTIN(StringEqual)
|
|
|
|
TFS_BUILTIN(StringLessThan)
|
|
|
|
TFS_BUILTIN(StringLessThanOrEqual)
|
|
|
|
TFS_BUILTIN(StringGreaterThan)
|
|
|
|
TFS_BUILTIN(StringGreaterThanOrEqual)
|
2016-03-23 13:44:32 +00:00
|
|
|
|
2016-11-18 06:30:57 +00:00
|
|
|
#undef TFS_BUILTIN
|
|
|
|
|
2014-09-11 13:18:58 +00:00
|
|
|
// static
|
|
|
|
Callable CodeFactory::StringAdd(Isolate* isolate, StringAddFlags flags,
|
|
|
|
PretenureFlag pretenure_flag) {
|
|
|
|
StringAddStub stub(isolate, flags, pretenure_flag);
|
2016-07-27 12:00:04 +00:00
|
|
|
return make_callable(stub);
|
2014-09-11 13:18:58 +00:00
|
|
|
}
|
|
|
|
|
2015-09-18 08:30:22 +00:00
|
|
|
// static
|
2016-03-04 09:38:31 +00:00
|
|
|
Callable CodeFactory::StringCompare(Isolate* isolate, Token::Value token) {
|
|
|
|
switch (token) {
|
|
|
|
case Token::EQ:
|
|
|
|
case Token::EQ_STRICT:
|
|
|
|
return StringEqual(isolate);
|
|
|
|
case Token::LT:
|
|
|
|
return StringLessThan(isolate);
|
|
|
|
case Token::GT:
|
|
|
|
return StringGreaterThan(isolate);
|
|
|
|
case Token::LTE:
|
|
|
|
return StringLessThanOrEqual(isolate);
|
|
|
|
case Token::GTE:
|
|
|
|
return StringGreaterThanOrEqual(isolate);
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
UNREACHABLE();
|
|
|
|
return StringEqual(isolate);
|
2015-09-18 08:30:22 +00:00
|
|
|
}
|
|
|
|
|
2017-01-26 12:46:44 +00:00
|
|
|
// static
|
|
|
|
Callable CodeFactory::StringIndexOf(Isolate* isolate) {
|
|
|
|
return Callable(isolate->builtins()->StringIndexOf(),
|
|
|
|
StringIndexOfDescriptor(isolate));
|
|
|
|
}
|
|
|
|
|
2015-12-11 09:11:26 +00:00
|
|
|
// static
|
|
|
|
Callable CodeFactory::SubString(Isolate* isolate) {
|
|
|
|
SubStringStub stub(isolate);
|
|
|
|
return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor());
|
|
|
|
}
|
|
|
|
|
2016-04-06 08:37:09 +00:00
|
|
|
// static
|
|
|
|
Callable CodeFactory::ResumeGenerator(Isolate* isolate) {
|
|
|
|
return Callable(isolate->builtins()->ResumeGeneratorTrampoline(),
|
|
|
|
ResumeGeneratorDescriptor(isolate));
|
|
|
|
}
|
|
|
|
|
2017-01-27 07:31:03 +00:00
|
|
|
// static
|
|
|
|
Callable CodeFactory::FrameDropperTrampoline(Isolate* isolate) {
|
|
|
|
return Callable(isolate->builtins()->FrameDropperTrampoline(),
|
|
|
|
FrameDropperTrampolineDescriptor(isolate));
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
Callable CodeFactory::HandleDebuggerStatement(Isolate* isolate) {
|
|
|
|
return Callable(isolate->builtins()->HandleDebuggerStatement(),
|
|
|
|
ContextOnlyDescriptor(isolate));
|
|
|
|
}
|
|
|
|
|
2015-04-21 15:43:31 +00:00
|
|
|
// static
|
2016-12-29 13:02:08 +00:00
|
|
|
Callable CodeFactory::FastCloneShallowArray(
|
|
|
|
Isolate* isolate, AllocationSiteMode allocation_mode) {
|
|
|
|
return Callable(isolate->builtins()->NewCloneShallowArray(allocation_mode),
|
|
|
|
FastCloneShallowArrayDescriptor(isolate));
|
2015-04-21 15:43:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
Callable CodeFactory::FastCloneShallowObject(Isolate* isolate, int length) {
|
2016-12-29 13:02:08 +00:00
|
|
|
return Callable(isolate->builtins()->NewCloneShallowObject(length),
|
|
|
|
FastCloneShallowObjectDescriptor(isolate));
|
2015-04-21 15:43:31 +00:00
|
|
|
}
|
|
|
|
|
2015-10-02 09:30:15 +00:00
|
|
|
// static
|
2016-12-20 16:23:19 +00:00
|
|
|
Callable CodeFactory::FastNewFunctionContext(Isolate* isolate,
|
|
|
|
ScopeType scope_type) {
|
2016-12-29 11:52:40 +00:00
|
|
|
return Callable(isolate->builtins()->NewFunctionContext(scope_type),
|
|
|
|
FastNewFunctionContextDescriptor(isolate));
|
2015-10-02 09:30:15 +00:00
|
|
|
}
|
|
|
|
|
[runtime] Optimize and unify rest parameters.
Replace the somewhat awkward RestParamAccessStub, which would always
call into the runtime anyway with a proper FastNewRestParameterStub,
which is basically based on the code that was already there for strict
arguments object materialization. But for rest parameters we could
optimize even further (leading to 8-10x improvements for functions with
rest parameters), by fixing the internal formal parameter count:
Every SharedFunctionInfo has a formal_parameter_count field, which
specifies the number of formal parameters, and is used to decide whether
we need to create an arguments adaptor frame when calling a function
(i.e. if there's a mismatch between the actual and expected parameters).
Previously the formal_parameter_count included the rest parameter, which
was sort of unfortunate, as that meant that calling a function with only
the non-rest parameters still required an arguments adaptor (plus some
other oddities). Now with this CL we fix, so that we do no longer
include the rest parameter in that count. Thereby checking for rest
parameters is very efficient, as we only need to check whether there is
an arguments adaptor frame, and if not create an empty array, otherwise
check whether the arguments adaptor frame has more parameters than
specified by the formal_parameter_count.
The FastNewRestParameterStub is written in a way that it can be directly
used by Ignition as well, and with some tweaks to the TurboFan backends
and the CodeStubAssembler, we should be able to rewrite it as
TurboFanCodeStub in the near future.
Drive-by-fix: Refactor and unify the CreateArgumentsType which was
different in TurboFan and Ignition; now we have a single enum class
which is used in both TurboFan and Ignition.
R=jarin@chromium.org, rmcilroy@chromium.org
TBR=rossberg@chromium.org
BUG=v8:2159
LOG=n
Review URL: https://codereview.chromium.org/1676883002
Cr-Commit-Position: refs/heads/master@{#33809}
2016-02-08 10:08:21 +00:00
|
|
|
// static
|
2017-02-07 16:02:44 +00:00
|
|
|
Callable CodeFactory::FastNewRestParameter(Isolate* isolate) {
|
|
|
|
return Callable(isolate->builtins()->FastNewRestParameter(),
|
|
|
|
FastNewRestParameterDescriptor(isolate));
|
[runtime] Optimize and unify rest parameters.
Replace the somewhat awkward RestParamAccessStub, which would always
call into the runtime anyway with a proper FastNewRestParameterStub,
which is basically based on the code that was already there for strict
arguments object materialization. But for rest parameters we could
optimize even further (leading to 8-10x improvements for functions with
rest parameters), by fixing the internal formal parameter count:
Every SharedFunctionInfo has a formal_parameter_count field, which
specifies the number of formal parameters, and is used to decide whether
we need to create an arguments adaptor frame when calling a function
(i.e. if there's a mismatch between the actual and expected parameters).
Previously the formal_parameter_count included the rest parameter, which
was sort of unfortunate, as that meant that calling a function with only
the non-rest parameters still required an arguments adaptor (plus some
other oddities). Now with this CL we fix, so that we do no longer
include the rest parameter in that count. Thereby checking for rest
parameters is very efficient, as we only need to check whether there is
an arguments adaptor frame, and if not create an empty array, otherwise
check whether the arguments adaptor frame has more parameters than
specified by the formal_parameter_count.
The FastNewRestParameterStub is written in a way that it can be directly
used by Ignition as well, and with some tweaks to the TurboFan backends
and the CodeStubAssembler, we should be able to rewrite it as
TurboFanCodeStub in the near future.
Drive-by-fix: Refactor and unify the CreateArgumentsType which was
different in TurboFan and Ignition; now we have a single enum class
which is used in both TurboFan and Ignition.
R=jarin@chromium.org, rmcilroy@chromium.org
TBR=rossberg@chromium.org
BUG=v8:2159
LOG=n
Review URL: https://codereview.chromium.org/1676883002
Cr-Commit-Position: refs/heads/master@{#33809}
2016-02-08 10:08:21 +00:00
|
|
|
}
|
|
|
|
|
2016-02-12 05:10:38 +00:00
|
|
|
// static
|
2017-02-07 16:02:44 +00:00
|
|
|
Callable CodeFactory::FastNewSloppyArguments(Isolate* isolate) {
|
|
|
|
return Callable(isolate->builtins()->FastNewSloppyArguments(),
|
|
|
|
FastNewRestParameterDescriptor(isolate));
|
2016-02-12 05:10:38 +00:00
|
|
|
}
|
|
|
|
|
2015-09-24 15:30:30 +00:00
|
|
|
// static
|
2017-02-07 16:02:44 +00:00
|
|
|
Callable CodeFactory::FastNewStrictArguments(Isolate* isolate) {
|
|
|
|
return Callable(isolate->builtins()->FastNewStrictArguments(),
|
|
|
|
FastNewRestParameterDescriptor(isolate));
|
2015-09-24 15:30:30 +00:00
|
|
|
}
|
|
|
|
|
2017-02-08 14:26:56 +00:00
|
|
|
// static
|
|
|
|
Callable CodeFactory::ForInPrepare(Isolate* isolate) {
|
|
|
|
return Callable(isolate->builtins()->ForInPrepare(),
|
|
|
|
ForInPrepareDescriptor(isolate));
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
Callable CodeFactory::ForInNext(Isolate* isolate) {
|
|
|
|
return Callable(isolate->builtins()->ForInNext(),
|
|
|
|
ForInNextDescriptor(isolate));
|
|
|
|
}
|
|
|
|
|
2014-11-04 12:58:17 +00:00
|
|
|
// static
|
|
|
|
Callable CodeFactory::AllocateHeapNumber(Isolate* isolate) {
|
|
|
|
AllocateHeapNumberStub stub(isolate);
|
2016-07-27 12:00:04 +00:00
|
|
|
return make_callable(stub);
|
2014-11-04 12:58:17 +00:00
|
|
|
}
|
|
|
|
|
2015-11-04 11:53:08 +00:00
|
|
|
// static
|
|
|
|
Callable CodeFactory::ArgumentAdaptor(Isolate* isolate) {
|
|
|
|
return Callable(isolate->builtins()->ArgumentsAdaptorTrampoline(),
|
|
|
|
ArgumentAdaptorDescriptor(isolate));
|
|
|
|
}
|
|
|
|
|
2015-11-04 15:04:19 +00:00
|
|
|
// static
|
2016-03-07 14:33:54 +00:00
|
|
|
Callable CodeFactory::Call(Isolate* isolate, ConvertReceiverMode mode,
|
|
|
|
TailCallMode tail_call_mode) {
|
|
|
|
return Callable(isolate->builtins()->Call(mode, tail_call_mode),
|
2015-11-04 15:04:19 +00:00
|
|
|
CallTrampolineDescriptor(isolate));
|
|
|
|
}
|
|
|
|
|
2017-01-24 14:37:01 +00:00
|
|
|
// static
|
|
|
|
Callable CodeFactory::CallWithSpread(Isolate* isolate) {
|
|
|
|
return Callable(isolate->builtins()->CallWithSpread(),
|
|
|
|
CallTrampolineDescriptor(isolate));
|
|
|
|
}
|
|
|
|
|
2015-11-05 13:30:41 +00:00
|
|
|
// static
|
2017-02-02 13:29:33 +00:00
|
|
|
Callable CodeFactory::CallFunction(Isolate* isolate, ConvertReceiverMode mode,
|
|
|
|
TailCallMode tail_call_mode) {
|
|
|
|
return Callable(isolate->builtins()->CallFunction(mode, tail_call_mode),
|
2015-11-05 13:30:41 +00:00
|
|
|
CallTrampolineDescriptor(isolate));
|
|
|
|
}
|
|
|
|
|
2017-01-26 09:29:56 +00:00
|
|
|
// static
|
|
|
|
Callable CodeFactory::CallForwardVarargs(Isolate* isolate) {
|
|
|
|
return Callable(isolate->builtins()->CallForwardVarargs(),
|
|
|
|
CallForwardVarargsDescriptor(isolate));
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
Callable CodeFactory::CallFunctionForwardVarargs(Isolate* isolate) {
|
|
|
|
return Callable(isolate->builtins()->CallFunctionForwardVarargs(),
|
|
|
|
CallForwardVarargsDescriptor(isolate));
|
|
|
|
}
|
|
|
|
|
2015-11-23 10:34:04 +00:00
|
|
|
// static
|
|
|
|
Callable CodeFactory::Construct(Isolate* isolate) {
|
|
|
|
return Callable(isolate->builtins()->Construct(),
|
|
|
|
ConstructTrampolineDescriptor(isolate));
|
|
|
|
}
|
|
|
|
|
2017-01-18 10:34:24 +00:00
|
|
|
// static
|
|
|
|
Callable CodeFactory::ConstructWithSpread(Isolate* isolate) {
|
|
|
|
return Callable(isolate->builtins()->ConstructWithSpread(),
|
|
|
|
ConstructTrampolineDescriptor(isolate));
|
|
|
|
}
|
|
|
|
|
2015-12-10 06:03:37 +00:00
|
|
|
// static
|
|
|
|
Callable CodeFactory::ConstructFunction(Isolate* isolate) {
|
|
|
|
return Callable(isolate->builtins()->ConstructFunction(),
|
|
|
|
ConstructTrampolineDescriptor(isolate));
|
|
|
|
}
|
|
|
|
|
2015-09-14 10:05:18 +00:00
|
|
|
// static
|
2016-02-17 15:19:02 +00:00
|
|
|
Callable CodeFactory::InterpreterPushArgsAndCall(Isolate* isolate,
|
2016-07-13 07:58:40 +00:00
|
|
|
TailCallMode tail_call_mode,
|
2017-01-24 14:37:01 +00:00
|
|
|
InterpreterPushArgsMode mode) {
|
|
|
|
return Callable(
|
|
|
|
isolate->builtins()->InterpreterPushArgsAndCall(tail_call_mode, mode),
|
|
|
|
InterpreterPushArgsAndCallDescriptor(isolate));
|
2015-10-02 18:13:41 +00:00
|
|
|
}
|
|
|
|
|
2015-10-15 16:46:16 +00:00
|
|
|
// static
|
2016-09-02 08:26:36 +00:00
|
|
|
Callable CodeFactory::InterpreterPushArgsAndConstruct(
|
2017-01-24 14:37:01 +00:00
|
|
|
Isolate* isolate, InterpreterPushArgsMode mode) {
|
2017-01-18 10:34:24 +00:00
|
|
|
return Callable(isolate->builtins()->InterpreterPushArgsAndConstruct(mode),
|
|
|
|
InterpreterPushArgsAndConstructDescriptor(isolate));
|
2015-10-15 16:46:16 +00:00
|
|
|
}
|
|
|
|
|
2016-09-08 14:49:24 +00:00
|
|
|
// static
|
|
|
|
Callable CodeFactory::InterpreterPushArgsAndConstructArray(Isolate* isolate) {
|
|
|
|
return Callable(isolate->builtins()->InterpreterPushArgsAndConstructArray(),
|
|
|
|
InterpreterPushArgsAndConstructArrayDescriptor(isolate));
|
|
|
|
}
|
|
|
|
|
2015-10-02 18:13:41 +00:00
|
|
|
// static
|
2016-01-08 15:15:52 +00:00
|
|
|
Callable CodeFactory::InterpreterCEntry(Isolate* isolate, int result_size) {
|
2015-10-02 18:13:41 +00:00
|
|
|
// Note: If we ever use fpregs in the interpreter then we will need to
|
|
|
|
// save fpregs too.
|
2016-01-08 15:15:52 +00:00
|
|
|
CEntryStub stub(isolate, result_size, kDontSaveFPRegs, kArgvInRegister);
|
2015-10-02 18:13:41 +00:00
|
|
|
return Callable(stub.GetCode(), InterpreterCEntryDescriptor(isolate));
|
2015-09-14 10:05:18 +00:00
|
|
|
}
|
|
|
|
|
2016-07-26 14:31:10 +00:00
|
|
|
// static
|
|
|
|
Callable CodeFactory::InterpreterOnStackReplacement(Isolate* isolate) {
|
|
|
|
return Callable(isolate->builtins()->InterpreterOnStackReplacement(),
|
|
|
|
ContextOnlyDescriptor(isolate));
|
|
|
|
}
|
|
|
|
|
2017-02-02 13:29:33 +00:00
|
|
|
// static
|
|
|
|
Callable CodeFactory::ArrayConstructor(Isolate* isolate) {
|
|
|
|
ArrayConstructorStub stub(isolate);
|
|
|
|
return make_callable(stub);
|
|
|
|
}
|
|
|
|
|
2016-11-29 16:57:58 +00:00
|
|
|
// static
|
|
|
|
Callable CodeFactory::ArrayPush(Isolate* isolate) {
|
|
|
|
return Callable(isolate->builtins()->ArrayPush(), BuiltinDescriptor(isolate));
|
|
|
|
}
|
|
|
|
|
[builtins] Separate Array.prototype.* CSA builtins into two parts
Previous to this CL, CSA-optimized Array builtins--like forEach, some, and
every--were written in a single, monolithic block of CSA code.
This CL teases the code for each of these builtins apart into two chunks, a main
body with optimizations for fast cases, and a "continuation" builtin that
performs a spec-compliant, but slower version of the main loop of the
builtin. The general idea is that when the "fast" main body builtin encounters
an unexpected condition that invalidates assumptions allowing fast-case code, it
tail calls to the slow, correct version of the loop that finishes the builtin
execution.
This separation currently doens't really provide any specific advantage over the
combined version. However, it paves the way to TF-optimized inlined Array
builtins. Inlined Array builtins may trigger deopts during the execution of the
builtin's loop, and those deopt must continue execution from the point at which
they failed. With some massaging of the deoptimizer, it will be possible to make
those deopt points create an extra frame on the top of the stack which resumes
execution in the slow-loop builtin created in this CL.
BUG=v8:1956
LOG=N
Review-Url: https://codereview.chromium.org/2753793002
Cr-Commit-Position: refs/heads/master@{#43867}
2017-03-16 15:34:01 +00:00
|
|
|
// static
|
|
|
|
Callable CodeFactory::ArrayForEachLoopContinuation(Isolate* isolate) {
|
|
|
|
return Callable(isolate->builtins()->ArrayForEachLoopContinuation(),
|
|
|
|
IteratingArrayBuiltinLoopContinuationDescriptor(isolate));
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
Callable CodeFactory::ArraySomeLoopContinuation(Isolate* isolate) {
|
|
|
|
return Callable(isolate->builtins()->ArraySomeLoopContinuation(),
|
|
|
|
IteratingArrayBuiltinLoopContinuationDescriptor(isolate));
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
Callable CodeFactory::ArrayEveryLoopContinuation(Isolate* isolate) {
|
|
|
|
return Callable(isolate->builtins()->ArrayEveryLoopContinuation(),
|
|
|
|
IteratingArrayBuiltinLoopContinuationDescriptor(isolate));
|
|
|
|
}
|
|
|
|
|
2016-12-01 21:15:08 +00:00
|
|
|
// static
|
|
|
|
Callable CodeFactory::FunctionPrototypeBind(Isolate* isolate) {
|
|
|
|
return Callable(isolate->builtins()->FunctionPrototypeBind(),
|
|
|
|
BuiltinDescriptor(isolate));
|
|
|
|
}
|
|
|
|
|
2014-09-11 13:18:58 +00:00
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|