Commit c205c9b7 authored by danno's avatar danno Committed by Commit bot

[builtins] Port parameter and argument-related code stubs to CSA

Includes the port of these three builtins: FastNewStrictArguments,
FastNewSloppyArguments and FastNewRestParameter. Also inline
the implementation of these into the corresponding interpreter
byte codes.

BUG=v8:5269
LOG=N
R=ishell@chromium.org, rmcilroy@chromium.org

Review-Url: https://codereview.chromium.org/2645743002
Cr-Commit-Position: refs/heads/master@{#43002}
parent 4d8bde0c
...@@ -972,6 +972,8 @@ v8_source_set("v8_base") { ...@@ -972,6 +972,8 @@ v8_source_set("v8_base") {
"src/bootstrapper.cc", "src/bootstrapper.cc",
"src/bootstrapper.h", "src/bootstrapper.h",
"src/builtins/builtins-api.cc", "src/builtins/builtins-api.cc",
"src/builtins/builtins-arguments.cc",
"src/builtins/builtins-arguments.h",
"src/builtins/builtins-array.cc", "src/builtins/builtins-array.cc",
"src/builtins/builtins-arraybuffer.cc", "src/builtins/builtins-arraybuffer.cc",
"src/builtins/builtins-async-function.cc", "src/builtins/builtins-async-function.cc",
......
This diff is collapsed.
...@@ -70,27 +70,6 @@ void FastNewClosureDescriptor::InitializePlatformSpecific( ...@@ -70,27 +70,6 @@ void FastNewClosureDescriptor::InitializePlatformSpecific(
data->InitializePlatformSpecific(arraysize(registers), registers); data->InitializePlatformSpecific(arraysize(registers), registers);
} }
void FastNewRestParameterDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {r1};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void FastNewSloppyArgumentsDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {r1};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void FastNewStrictArgumentsDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {r1};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
// static // static
const Register TypeConversionDescriptor::ArgumentRegister() { return r0; } const Register TypeConversionDescriptor::ArgumentRegister() { return r0; }
......
This diff is collapsed.
...@@ -71,30 +71,6 @@ void FastNewClosureDescriptor::InitializePlatformSpecific( ...@@ -71,30 +71,6 @@ void FastNewClosureDescriptor::InitializePlatformSpecific(
data->InitializePlatformSpecific(arraysize(registers), registers); data->InitializePlatformSpecific(arraysize(registers), registers);
} }
void FastNewRestParameterDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// x1: function
Register registers[] = {x1};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void FastNewSloppyArgumentsDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// x1: function
Register registers[] = {x1};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void FastNewStrictArgumentsDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// x1: function
Register registers[] = {x1};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
// static // static
const Register TypeConversionDescriptor::ArgumentRegister() { return x0; } const Register TypeConversionDescriptor::ArgumentRegister() { return x0; }
......
This diff is collapsed.
// Copyright 2017 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.
#include "src/code-stub-assembler.h"
namespace v8 {
namespace internal {
typedef compiler::Node Node;
typedef compiler::CodeAssemblerState CodeAssemblerState;
typedef compiler::CodeAssemblerLabel CodeAssemblerLabel;
class ArgumentsBuiltinsAssembler : public CodeStubAssembler {
public:
explicit ArgumentsBuiltinsAssembler(CodeAssemblerState* state)
: CodeStubAssembler(state) {}
Node* EmitFastNewStrictArguments(Node* context, Node* function);
Node* EmitFastNewSloppyArguments(Node* context, Node* function);
Node* EmitFastNewRestParameter(Node* context, Node* function);
private:
// Calculates and returns the the frame pointer, argument count and formal
// parameter count to be used to access a function's parameters, taking
// argument adapter frames into account. The tuple is of the form:
// <frame_ptr, # parameters actually passed, formal parameter count>
std::tuple<Node*, Node*, Node*> GetArgumentsFrameAndCount(Node* function,
ParameterMode mode);
// Allocates an an arguments (either rest, strict or sloppy) together with the
// FixedArray elements for the arguments and a parameter map (for sloppy
// arguments only). A tuple is returned with pointers to the arguments object,
// the elements and parameter map in the form:
// <argument object, arguments FixedArray, parameter map or nullptr>
std::tuple<Node*, Node*, Node*> AllocateArgumentsObject(
Node* map, Node* arguments, Node* mapped_arguments,
ParameterMode param_mode, int base_size);
// For Rest parameters and Strict arguments, the copying of parameters from
// the stack into the arguments object is straight-forward and shares much of
// the same underlying logic, which is encapsulated by this function. It
// allocates an arguments-like object of size |base_size| with the map |map|,
// and then copies |rest_count| arguments from the stack frame pointed to by
// |frame_ptr| starting from |first_arg|. |arg_count| == |first_arg| +
// |rest_count|.
Node* ConstructParametersObjectFromArgs(Node* map, Node* frame_ptr,
Node* arg_count, Node* first_arg,
Node* rest_count,
ParameterMode param_mode,
int base_size);
};
} // namespace internal
} // namespace v8
...@@ -103,6 +103,9 @@ class Isolate; ...@@ -103,6 +103,9 @@ class Isolate;
FastNewFunctionContext) \ FastNewFunctionContext) \
TFS(FastNewFunctionContextFunction, BUILTIN, kNoExtraICState, \ TFS(FastNewFunctionContextFunction, BUILTIN, kNoExtraICState, \
FastNewFunctionContext) \ FastNewFunctionContext) \
TFS(FastNewStrictArguments, BUILTIN, kNoExtraICState, FastNewArguments) \
TFS(FastNewSloppyArguments, BUILTIN, kNoExtraICState, FastNewArguments) \
TFS(FastNewRestParameter, BUILTIN, kNoExtraICState, FastNewArguments) \
TFS(FastCloneRegExp, BUILTIN, kNoExtraICState, FastCloneRegExp) \ TFS(FastCloneRegExp, BUILTIN, kNoExtraICState, FastCloneRegExp) \
TFS(FastCloneShallowArrayTrack, BUILTIN, kNoExtraICState, \ TFS(FastCloneShallowArrayTrack, BUILTIN, kNoExtraICState, \
FastCloneShallowArray) \ FastCloneShallowArray) \
......
...@@ -346,24 +346,21 @@ Callable CodeFactory::FastNewFunctionContext(Isolate* isolate, ...@@ -346,24 +346,21 @@ Callable CodeFactory::FastNewFunctionContext(Isolate* isolate,
} }
// static // static
Callable CodeFactory::FastNewRestParameter(Isolate* isolate, Callable CodeFactory::FastNewRestParameter(Isolate* isolate) {
bool skip_stub_frame) { return Callable(isolate->builtins()->FastNewRestParameter(),
FastNewRestParameterStub stub(isolate, skip_stub_frame); FastNewRestParameterDescriptor(isolate));
return make_callable(stub);
} }
// static // static
Callable CodeFactory::FastNewSloppyArguments(Isolate* isolate, Callable CodeFactory::FastNewSloppyArguments(Isolate* isolate) {
bool skip_stub_frame) { return Callable(isolate->builtins()->FastNewSloppyArguments(),
FastNewSloppyArgumentsStub stub(isolate, skip_stub_frame); FastNewRestParameterDescriptor(isolate));
return make_callable(stub);
} }
// static // static
Callable CodeFactory::FastNewStrictArguments(Isolate* isolate, Callable CodeFactory::FastNewStrictArguments(Isolate* isolate) {
bool skip_stub_frame) { return Callable(isolate->builtins()->FastNewStrictArguments(),
FastNewStrictArgumentsStub stub(isolate, skip_stub_frame); FastNewRestParameterDescriptor(isolate));
return make_callable(stub);
} }
// static // static
......
...@@ -148,12 +148,9 @@ class V8_EXPORT_PRIVATE CodeFactory final { ...@@ -148,12 +148,9 @@ class V8_EXPORT_PRIVATE CodeFactory final {
ScopeType scope_type); ScopeType scope_type);
static Callable FastNewClosure(Isolate* isolate); static Callable FastNewClosure(Isolate* isolate);
static Callable FastNewObject(Isolate* isolate); static Callable FastNewObject(Isolate* isolate);
static Callable FastNewRestParameter(Isolate* isolate, static Callable FastNewRestParameter(Isolate* isolate);
bool skip_stub_frame = false); static Callable FastNewSloppyArguments(Isolate* isolate);
static Callable FastNewSloppyArguments(Isolate* isolate, static Callable FastNewStrictArguments(Isolate* isolate);
bool skip_stub_frame = false);
static Callable FastNewStrictArguments(Isolate* isolate,
bool skip_stub_frame = false);
static Callable CopyFastSmiOrObjectElements(Isolate* isolate); static Callable CopyFastSmiOrObjectElements(Isolate* isolate);
static Callable GrowFastDoubleElements(Isolate* isolate); static Callable GrowFastDoubleElements(Isolate* isolate);
......
...@@ -1201,6 +1201,25 @@ Node* CodeStubAssembler::LoadMapConstructor(Node* map) { ...@@ -1201,6 +1201,25 @@ Node* CodeStubAssembler::LoadMapConstructor(Node* map) {
return result.value(); return result.value();
} }
Node* CodeStubAssembler::LoadSharedFunctionInfoSpecialField(
Node* shared, int offset, ParameterMode mode) {
if (Is64()) {
Node* result = LoadObjectField(shared, offset, MachineType::Int32());
if (mode == SMI_PARAMETERS) {
result = SmiTag(result);
} else {
result = ChangeUint32ToWord(result);
}
return result;
} else {
Node* result = LoadObjectField(shared, offset);
if (mode != SMI_PARAMETERS) {
result = SmiUntag(result);
}
return result;
}
}
Node* CodeStubAssembler::LoadNameHashField(Node* name) { Node* CodeStubAssembler::LoadNameHashField(Node* name) {
CSA_ASSERT(this, IsName(name)); CSA_ASSERT(this, IsName(name));
return LoadObjectField(name, Name::kHashFieldOffset, MachineType::Uint32()); return LoadObjectField(name, Name::kHashFieldOffset, MachineType::Uint32());
...@@ -6287,6 +6306,16 @@ void CodeStubAssembler::BuildFastFixedArrayForEach( ...@@ -6287,6 +6306,16 @@ void CodeStubAssembler::BuildFastFixedArrayForEach(
: IndexAdvanceMode::kPost); : IndexAdvanceMode::kPost);
} }
void CodeStubAssembler::GotoIfFixedArraySizeDoesntFitInNewSpace(
Node* element_count, Label* doesnt_fit, int base_size, ParameterMode mode) {
int max_newspace_parameters =
(kMaxRegularHeapObjectSize - base_size) / kPointerSize;
GotoIf(IntPtrOrSmiGreaterThan(
element_count, IntPtrOrSmiConstant(max_newspace_parameters, mode),
mode),
doesnt_fit);
}
void CodeStubAssembler::InitializeFieldsWithRoot( void CodeStubAssembler::InitializeFieldsWithRoot(
Node* object, Node* start_offset, Node* end_offset, Node* object, Node* start_offset, Node* end_offset,
Heap::RootListIndex root_index) { Heap::RootListIndex root_index) {
......
...@@ -77,10 +77,13 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler { ...@@ -77,10 +77,13 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
return Is64() ? INTPTR_PARAMETERS : SMI_PARAMETERS; return Is64() ? INTPTR_PARAMETERS : SMI_PARAMETERS;
} }
MachineRepresentation ParameterRepresentation(ParameterMode mode) const {
return mode == INTPTR_PARAMETERS ? MachineType::PointerRepresentation()
: MachineRepresentation::kTaggedSigned;
}
MachineRepresentation OptimalParameterRepresentation() const { MachineRepresentation OptimalParameterRepresentation() const {
return OptimalParameterMode() == INTPTR_PARAMETERS return ParameterRepresentation(OptimalParameterMode());
? MachineType::PointerRepresentation()
: MachineRepresentation::kTaggedSigned;
} }
Node* ParameterToWord(Node* value, ParameterMode mode) { Node* ParameterToWord(Node* value, ParameterMode mode) {
...@@ -384,6 +387,14 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler { ...@@ -384,6 +387,14 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
Node* LoadMapConstructorFunctionIndex(Node* map); Node* LoadMapConstructorFunctionIndex(Node* map);
// Load the constructor of a Map (equivalent to Map::GetConstructor()). // Load the constructor of a Map (equivalent to Map::GetConstructor()).
Node* LoadMapConstructor(Node* map); Node* LoadMapConstructor(Node* map);
// Loads a value from the specially encoded integer fields in the
// SharedFunctionInfo object.
// TODO(danno): This currently only works for the integer fields that are
// mapped to the upper part of 64-bit words. We should customize
// SFI::BodyDescriptor and store int32 values directly.
Node* LoadSharedFunctionInfoSpecialField(Node* shared, int offset,
ParameterMode param_mode);
// Check if the map is set for slow properties. // Check if the map is set for slow properties.
Node* IsDictionaryMap(Node* map); Node* IsDictionaryMap(Node* map);
...@@ -1114,6 +1125,10 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler { ...@@ -1114,6 +1125,10 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
FixedArray::kHeaderSize); FixedArray::kHeaderSize);
} }
void GotoIfFixedArraySizeDoesntFitInNewSpace(Node* element_count,
Label* doesnt_fit, int base_size,
ParameterMode mode);
void InitializeFieldsWithRoot(Node* object, Node* start_offset, void InitializeFieldsWithRoot(Node* object, Node* start_offset,
Node* end_offset, Heap::RootListIndex root); Node* end_offset, Heap::RootListIndex root);
......
...@@ -49,9 +49,6 @@ class Node; ...@@ -49,9 +49,6 @@ class Node;
V(StoreBufferOverflow) \ V(StoreBufferOverflow) \
V(StoreSlowElement) \ V(StoreSlowElement) \
V(SubString) \ V(SubString) \
V(FastNewRestParameter) \
V(FastNewSloppyArguments) \
V(FastNewStrictArguments) \
V(NameDictionaryLookup) \ V(NameDictionaryLookup) \
/* This can be removed once there are no */ \ /* This can be removed once there are no */ \
/* more deopting Hydrogen stubs. */ \ /* more deopting Hydrogen stubs. */ \
...@@ -748,69 +745,6 @@ class NumberToStringStub final : public TurboFanCodeStub { ...@@ -748,69 +745,6 @@ class NumberToStringStub final : public TurboFanCodeStub {
DEFINE_TURBOFAN_CODE_STUB(NumberToString, TurboFanCodeStub); DEFINE_TURBOFAN_CODE_STUB(NumberToString, TurboFanCodeStub);
}; };
// TODO(turbofan): This stub should be possible to write in TurboFan
// using the CodeStubAssembler very soon in a way that is as efficient
// and easy as the current handwritten version, which is partly a copy
// of the strict arguments object materialization code.
class FastNewRestParameterStub final : public PlatformCodeStub {
public:
explicit FastNewRestParameterStub(Isolate* isolate,
bool skip_stub_frame = false)
: PlatformCodeStub(isolate) {
minor_key_ = SkipStubFrameBits::encode(skip_stub_frame);
}
DEFINE_CALL_INTERFACE_DESCRIPTOR(FastNewRestParameter);
DEFINE_PLATFORM_CODE_STUB(FastNewRestParameter, PlatformCodeStub);
int skip_stub_frame() const { return SkipStubFrameBits::decode(minor_key_); }
private:
class SkipStubFrameBits : public BitField<bool, 0, 1> {};
};
// TODO(turbofan): This stub should be possible to write in TurboFan
// using the CodeStubAssembler very soon in a way that is as efficient
// and easy as the current handwritten version.
class FastNewSloppyArgumentsStub final : public PlatformCodeStub {
public:
explicit FastNewSloppyArgumentsStub(Isolate* isolate,
bool skip_stub_frame = false)
: PlatformCodeStub(isolate) {
minor_key_ = SkipStubFrameBits::encode(skip_stub_frame);
}
int skip_stub_frame() const { return SkipStubFrameBits::decode(minor_key_); }
DEFINE_CALL_INTERFACE_DESCRIPTOR(FastNewSloppyArguments);
DEFINE_PLATFORM_CODE_STUB(FastNewSloppyArguments, PlatformCodeStub);
private:
class SkipStubFrameBits : public BitField<bool, 0, 1> {};
};
// TODO(turbofan): This stub should be possible to write in TurboFan
// using the CodeStubAssembler very soon in a way that is as efficient
// and easy as the current handwritten version.
class FastNewStrictArgumentsStub final : public PlatformCodeStub {
public:
explicit FastNewStrictArgumentsStub(Isolate* isolate,
bool skip_stub_frame = false)
: PlatformCodeStub(isolate) {
minor_key_ = SkipStubFrameBits::encode(skip_stub_frame);
}
DEFINE_CALL_INTERFACE_DESCRIPTOR(FastNewStrictArguments);
DEFINE_PLATFORM_CODE_STUB(FastNewStrictArguments, PlatformCodeStub);
int skip_stub_frame() const { return SkipStubFrameBits::decode(minor_key_); }
private:
class SkipStubFrameBits : public BitField<bool, 0, 1> {};
};
class CreateAllocationSiteStub : public TurboFanCodeStub { class CreateAllocationSiteStub : public TurboFanCodeStub {
public: public:
explicit CreateAllocationSiteStub(Isolate* isolate) explicit CreateAllocationSiteStub(Isolate* isolate)
......
...@@ -271,14 +271,16 @@ void FullCodeGenerator::Generate() { ...@@ -271,14 +271,16 @@ void FullCodeGenerator::Generate() {
__ ldr(r1, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); __ ldr(r1, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
} }
if (is_strict(language_mode()) || !has_simple_parameters()) { if (is_strict(language_mode()) || !has_simple_parameters()) {
FastNewStrictArgumentsStub stub(isolate()); Callable callable = CodeFactory::FastNewStrictArguments(isolate());
__ CallStub(&stub); __ Call(callable.code(), RelocInfo::CODE_TARGET);
RestoreContext();
} else if (literal()->has_duplicate_parameters()) { } else if (literal()->has_duplicate_parameters()) {
__ Push(r1); __ Push(r1);
__ CallRuntime(Runtime::kNewSloppyArguments_Generic); __ CallRuntime(Runtime::kNewSloppyArguments_Generic);
} else { } else {
FastNewSloppyArgumentsStub stub(isolate()); Callable callable = CodeFactory::FastNewSloppyArguments(isolate());
__ CallStub(&stub); __ Call(callable.code(), RelocInfo::CODE_TARGET);
RestoreContext();
} }
SetVar(arguments, r0, r1, r2); SetVar(arguments, r0, r1, r2);
......
...@@ -273,14 +273,16 @@ void FullCodeGenerator::Generate() { ...@@ -273,14 +273,16 @@ void FullCodeGenerator::Generate() {
__ Ldr(x1, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); __ Ldr(x1, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
} }
if (is_strict(language_mode()) || !has_simple_parameters()) { if (is_strict(language_mode()) || !has_simple_parameters()) {
FastNewStrictArgumentsStub stub(isolate()); Callable callable = CodeFactory::FastNewStrictArguments(isolate());
__ CallStub(&stub); __ Call(callable.code(), RelocInfo::CODE_TARGET);
RestoreContext();
} else if (literal()->has_duplicate_parameters()) { } else if (literal()->has_duplicate_parameters()) {
__ Push(x1); __ Push(x1);
__ CallRuntime(Runtime::kNewSloppyArguments_Generic); __ CallRuntime(Runtime::kNewSloppyArguments_Generic);
} else { } else {
FastNewSloppyArgumentsStub stub(isolate()); Callable callable = CodeFactory::FastNewSloppyArguments(isolate());
__ CallStub(&stub); __ Call(callable.code(), RelocInfo::CODE_TARGET);
RestoreContext();
} }
SetVar(arguments, x0, x1, x2); SetVar(arguments, x0, x1, x2);
......
...@@ -263,14 +263,16 @@ void FullCodeGenerator::Generate() { ...@@ -263,14 +263,16 @@ void FullCodeGenerator::Generate() {
__ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); __ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
} }
if (is_strict(language_mode()) || !has_simple_parameters()) { if (is_strict(language_mode()) || !has_simple_parameters()) {
FastNewStrictArgumentsStub stub(isolate()); __ call(isolate()->builtins()->FastNewStrictArguments(),
__ CallStub(&stub); RelocInfo::CODE_TARGET);
RestoreContext();
} else if (literal()->has_duplicate_parameters()) { } else if (literal()->has_duplicate_parameters()) {
__ Push(edi); __ Push(edi);
__ CallRuntime(Runtime::kNewSloppyArguments_Generic); __ CallRuntime(Runtime::kNewSloppyArguments_Generic);
} else { } else {
FastNewSloppyArgumentsStub stub(isolate()); __ call(isolate()->builtins()->FastNewSloppyArguments(),
__ CallStub(&stub); RelocInfo::CODE_TARGET);
RestoreContext();
} }
SetVar(arguments, eax, ebx, edx); SetVar(arguments, eax, ebx, edx);
......
...@@ -281,14 +281,16 @@ void FullCodeGenerator::Generate() { ...@@ -281,14 +281,16 @@ void FullCodeGenerator::Generate() {
__ lw(a1, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); __ lw(a1, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
} }
if (is_strict(language_mode()) || !has_simple_parameters()) { if (is_strict(language_mode()) || !has_simple_parameters()) {
FastNewStrictArgumentsStub stub(isolate()); Callable callable = CodeFactory::FastNewStrictArguments(isolate());
__ CallStub(&stub); __ Call(callable.code(), RelocInfo::CODE_TARGET);
RestoreContext();
} else if (literal()->has_duplicate_parameters()) { } else if (literal()->has_duplicate_parameters()) {
__ Push(a1); __ Push(a1);
__ CallRuntime(Runtime::kNewSloppyArguments_Generic); __ CallRuntime(Runtime::kNewSloppyArguments_Generic);
} else { } else {
FastNewSloppyArgumentsStub stub(isolate()); Callable callable = CodeFactory::FastNewSloppyArguments(isolate());
__ CallStub(&stub); __ Call(callable.code(), RelocInfo::CODE_TARGET);
RestoreContext();
} }
SetVar(arguments, v0, a1, a2); SetVar(arguments, v0, a1, a2);
......
...@@ -280,14 +280,16 @@ void FullCodeGenerator::Generate() { ...@@ -280,14 +280,16 @@ void FullCodeGenerator::Generate() {
__ ld(a1, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); __ ld(a1, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
} }
if (is_strict(language_mode()) || !has_simple_parameters()) { if (is_strict(language_mode()) || !has_simple_parameters()) {
FastNewStrictArgumentsStub stub(isolate()); Callable callable = CodeFactory::FastNewStrictArguments(isolate());
__ CallStub(&stub); __ Call(callable.code(), RelocInfo::CODE_TARGET);
RestoreContext();
} else if (literal()->has_duplicate_parameters()) { } else if (literal()->has_duplicate_parameters()) {
__ Push(a1); __ Push(a1);
__ CallRuntime(Runtime::kNewSloppyArguments_Generic); __ CallRuntime(Runtime::kNewSloppyArguments_Generic);
} else { } else {
FastNewSloppyArgumentsStub stub(isolate()); Callable callable = CodeFactory::FastNewSloppyArguments(isolate());
__ CallStub(&stub); __ Call(callable.code(), RelocInfo::CODE_TARGET);
RestoreContext();
} }
SetVar(arguments, v0, a1, a2); SetVar(arguments, v0, a1, a2);
......
...@@ -260,14 +260,16 @@ void FullCodeGenerator::Generate() { ...@@ -260,14 +260,16 @@ void FullCodeGenerator::Generate() {
__ movp(rdi, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); __ movp(rdi, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
} }
if (is_strict(language_mode()) || !has_simple_parameters()) { if (is_strict(language_mode()) || !has_simple_parameters()) {
FastNewStrictArgumentsStub stub(isolate()); __ call(isolate()->builtins()->FastNewStrictArguments(),
__ CallStub(&stub); RelocInfo::CODE_TARGET);
RestoreContext();
} else if (literal()->has_duplicate_parameters()) { } else if (literal()->has_duplicate_parameters()) {
__ Push(rdi); __ Push(rdi);
__ CallRuntime(Runtime::kNewSloppyArguments_Generic); __ CallRuntime(Runtime::kNewSloppyArguments_Generic);
} else { } else {
FastNewSloppyArgumentsStub stub(isolate()); __ call(isolate()->builtins()->FastNewSloppyArguments(),
__ CallStub(&stub); RelocInfo::CODE_TARGET);
RestoreContext();
} }
SetVar(arguments, rax, rbx, rdx); SetVar(arguments, rax, rbx, rdx);
......
This diff is collapsed.
...@@ -69,27 +69,6 @@ void FastNewClosureDescriptor::InitializePlatformSpecific( ...@@ -69,27 +69,6 @@ void FastNewClosureDescriptor::InitializePlatformSpecific(
data->InitializePlatformSpecific(arraysize(registers), registers, NULL); data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
} }
void FastNewRestParameterDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {edi};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void FastNewSloppyArgumentsDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {edi};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void FastNewStrictArgumentsDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {edi};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
// static // static
const Register TypeConversionDescriptor::ArgumentRegister() { return eax; } const Register TypeConversionDescriptor::ArgumentRegister() { return eax; }
......
...@@ -88,6 +88,16 @@ const Register FastNewObjectDescriptor::NewTargetRegister() { ...@@ -88,6 +88,16 @@ const Register FastNewObjectDescriptor::NewTargetRegister() {
return kJavaScriptCallNewTargetRegister; return kJavaScriptCallNewTargetRegister;
} }
void FastNewArgumentsDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {TargetRegister()};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
const Register FastNewArgumentsDescriptor::TargetRegister() {
return kJSFunctionRegister;
}
void LoadDescriptor::InitializePlatformIndependent( void LoadDescriptor::InitializePlatformIndependent(
CallInterfaceDescriptorData* data) { CallInterfaceDescriptorData* data) {
// kReceiver, kName, kSlot // kReceiver, kName, kSlot
......
...@@ -33,9 +33,7 @@ class PlatformInterfaceDescriptor; ...@@ -33,9 +33,7 @@ class PlatformInterfaceDescriptor;
V(FastNewClosure) \ V(FastNewClosure) \
V(FastNewFunctionContext) \ V(FastNewFunctionContext) \
V(FastNewObject) \ V(FastNewObject) \
V(FastNewRestParameter) \ V(FastNewArguments) \
V(FastNewSloppyArguments) \
V(FastNewStrictArguments) \
V(TypeConversion) \ V(TypeConversion) \
V(Typeof) \ V(Typeof) \
V(FastCloneRegExp) \ V(FastCloneRegExp) \
...@@ -497,21 +495,11 @@ class FastNewObjectDescriptor : public CallInterfaceDescriptor { ...@@ -497,21 +495,11 @@ class FastNewObjectDescriptor : public CallInterfaceDescriptor {
static const Register NewTargetRegister(); static const Register NewTargetRegister();
}; };
class FastNewRestParameterDescriptor : public CallInterfaceDescriptor { class FastNewArgumentsDescriptor : public CallInterfaceDescriptor {
public: public:
DECLARE_DESCRIPTOR(FastNewRestParameterDescriptor, CallInterfaceDescriptor) DEFINE_PARAMETERS(kFunction)
}; DECLARE_DESCRIPTOR(FastNewArgumentsDescriptor, CallInterfaceDescriptor)
static const Register TargetRegister();
class FastNewSloppyArgumentsDescriptor : public CallInterfaceDescriptor {
public:
DECLARE_DESCRIPTOR(FastNewSloppyArgumentsDescriptor,
CallInterfaceDescriptor)
};
class FastNewStrictArgumentsDescriptor : public CallInterfaceDescriptor {
public:
DECLARE_DESCRIPTOR(FastNewStrictArgumentsDescriptor,
CallInterfaceDescriptor)
}; };
class TypeConversionDescriptor final : public CallInterfaceDescriptor { class TypeConversionDescriptor final : public CallInterfaceDescriptor {
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <memory> #include <memory>
#include "src/ast/prettyprinter.h" #include "src/ast/prettyprinter.h"
#include "src/builtins/builtins-arguments.h"
#include "src/builtins/builtins-constructor.h" #include "src/builtins/builtins-constructor.h"
#include "src/code-factory.h" #include "src/code-factory.h"
#include "src/compilation-info.h" #include "src/compilation-info.h"
...@@ -2935,10 +2936,9 @@ void Interpreter::DoCreateMappedArguments(InterpreterAssembler* assembler) { ...@@ -2935,10 +2936,9 @@ void Interpreter::DoCreateMappedArguments(InterpreterAssembler* assembler) {
__ Bind(&if_not_duplicate_parameters); __ Bind(&if_not_duplicate_parameters);
{ {
// TODO(rmcilroy): Inline FastNewSloppyArguments when it is a TurboFan stub. ArgumentsBuiltinsAssembler constructor_assembler(assembler->state());
Callable callable = CodeFactory::FastNewSloppyArguments(isolate_, true); Node* result =
Node* target = __ HeapConstant(callable.code()); constructor_assembler.EmitFastNewSloppyArguments(context, closure);
Node* result = __ CallStub(callable.descriptor(), target, context, closure);
__ SetAccumulator(result); __ SetAccumulator(result);
__ Dispatch(); __ Dispatch();
} }
...@@ -2956,12 +2956,11 @@ void Interpreter::DoCreateMappedArguments(InterpreterAssembler* assembler) { ...@@ -2956,12 +2956,11 @@ void Interpreter::DoCreateMappedArguments(InterpreterAssembler* assembler) {
// //
// Creates a new unmapped arguments object. // Creates a new unmapped arguments object.
void Interpreter::DoCreateUnmappedArguments(InterpreterAssembler* assembler) { void Interpreter::DoCreateUnmappedArguments(InterpreterAssembler* assembler) {
// TODO(rmcilroy): Inline FastNewStrictArguments when it is a TurboFan stub.
Callable callable = CodeFactory::FastNewStrictArguments(isolate_, true);
Node* target = __ HeapConstant(callable.code());
Node* context = __ GetContext(); Node* context = __ GetContext();
Node* closure = __ LoadRegister(Register::function_closure()); Node* closure = __ LoadRegister(Register::function_closure());
Node* result = __ CallStub(callable.descriptor(), target, context, closure); ArgumentsBuiltinsAssembler builtins_assembler(assembler->state());
Node* result =
builtins_assembler.EmitFastNewStrictArguments(context, closure);
__ SetAccumulator(result); __ SetAccumulator(result);
__ Dispatch(); __ Dispatch();
} }
...@@ -2970,12 +2969,10 @@ void Interpreter::DoCreateUnmappedArguments(InterpreterAssembler* assembler) { ...@@ -2970,12 +2969,10 @@ void Interpreter::DoCreateUnmappedArguments(InterpreterAssembler* assembler) {
// //
// Creates a new rest parameter array. // Creates a new rest parameter array.
void Interpreter::DoCreateRestParameter(InterpreterAssembler* assembler) { void Interpreter::DoCreateRestParameter(InterpreterAssembler* assembler) {
// TODO(rmcilroy): Inline FastNewRestArguments when it is a TurboFan stub.
Callable callable = CodeFactory::FastNewRestParameter(isolate_, true);
Node* target = __ HeapConstant(callable.code());
Node* closure = __ LoadRegister(Register::function_closure()); Node* closure = __ LoadRegister(Register::function_closure());
Node* context = __ GetContext(); Node* context = __ GetContext();
Node* result = __ CallStub(callable.descriptor(), target, context, closure); ArgumentsBuiltinsAssembler builtins_assembler(assembler->state());
Node* result = builtins_assembler.EmitFastNewRestParameter(context, closure);
__ SetAccumulator(result); __ SetAccumulator(result);
__ Dispatch(); __ Dispatch();
} }
......
This diff is collapsed.
...@@ -68,27 +68,6 @@ void FastNewClosureDescriptor::InitializePlatformSpecific( ...@@ -68,27 +68,6 @@ void FastNewClosureDescriptor::InitializePlatformSpecific(
data->InitializePlatformSpecific(arraysize(registers), registers, NULL); data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
} }
void FastNewRestParameterDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {a1};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void FastNewSloppyArgumentsDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {a1};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void FastNewStrictArgumentsDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {a1};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
// static // static
const Register TypeConversionDescriptor::ArgumentRegister() { return a0; } const Register TypeConversionDescriptor::ArgumentRegister() { return a0; }
......
This diff is collapsed.
...@@ -68,27 +68,6 @@ void FastNewClosureDescriptor::InitializePlatformSpecific( ...@@ -68,27 +68,6 @@ void FastNewClosureDescriptor::InitializePlatformSpecific(
data->InitializePlatformSpecific(arraysize(registers), registers, NULL); data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
} }
void FastNewRestParameterDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {a1};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void FastNewSloppyArgumentsDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {a1};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void FastNewStrictArgumentsDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {a1};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
// static // static
const Register TypeConversionDescriptor::ArgumentRegister() { return a0; } const Register TypeConversionDescriptor::ArgumentRegister() { return a0; }
......
...@@ -589,12 +589,29 @@ RUNTIME_FUNCTION(Runtime_NewRestParameter) { ...@@ -589,12 +589,29 @@ RUNTIME_FUNCTION(Runtime_NewRestParameter) {
RUNTIME_FUNCTION(Runtime_NewSloppyArguments) { RUNTIME_FUNCTION(Runtime_NewSloppyArguments) {
HandleScope scope(isolate); HandleScope scope(isolate);
DCHECK_EQ(3, args.length()); DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(JSFunction, callee, 0); CONVERT_ARG_HANDLE_CHECKED(JSFunction, callee, 0);
Object** parameters = reinterpret_cast<Object**>(args[1]); StackFrameIterator iterator(isolate);
CONVERT_SMI_ARG_CHECKED(argument_count, 2);
// Stub/interpreter handler frame
iterator.Advance();
DCHECK(iterator.frame()->type() == StackFrame::STUB);
// Function frame
iterator.Advance();
JavaScriptFrame* function_frame = JavaScriptFrame::cast(iterator.frame());
DCHECK(function_frame->is_java_script());
int argc = function_frame->GetArgumentsLength();
Address fp = function_frame->fp();
if (function_frame->has_adapted_arguments()) {
iterator.Advance();
fp = iterator.frame()->fp();
}
Object** parameters = reinterpret_cast<Object**>(
fp + argc * kPointerSize + StandardFrameConstants::kCallerSPOffset);
ParameterArguments argument_getter(parameters); ParameterArguments argument_getter(parameters);
return *NewSloppyArguments(isolate, callee, argument_getter, argument_count); return *NewSloppyArguments(isolate, callee, argument_getter, argc);
} }
RUNTIME_FUNCTION(Runtime_NewArgumentsElements) { RUNTIME_FUNCTION(Runtime_NewArgumentsElements) {
......
...@@ -476,6 +476,8 @@ ...@@ -476,6 +476,8 @@
'bootstrapper.cc', 'bootstrapper.cc',
'bootstrapper.h', 'bootstrapper.h',
'builtins/builtins-api.cc', 'builtins/builtins-api.cc',
'builtins/builtins-arguments.cc',
'builtins/builtins-arguments.h',
'builtins/builtins-arraybuffer.cc', 'builtins/builtins-arraybuffer.cc',
'builtins/builtins-array.cc', 'builtins/builtins-array.cc',
'builtins/builtins-async-function.cc', 'builtins/builtins-async-function.cc',
......
This diff is collapsed.
...@@ -69,25 +69,6 @@ void FastNewClosureDescriptor::InitializePlatformSpecific( ...@@ -69,25 +69,6 @@ void FastNewClosureDescriptor::InitializePlatformSpecific(
data->InitializePlatformSpecific(arraysize(registers), registers); data->InitializePlatformSpecific(arraysize(registers), registers);
} }
void FastNewRestParameterDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {rdi};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void FastNewSloppyArgumentsDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {rdi};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void FastNewStrictArgumentsDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {rdi};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void TypeofDescriptor::InitializePlatformSpecific( void TypeofDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) { CallInterfaceDescriptorData* data) {
Register registers[] = {rbx}; Register registers[] = {rbx};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment