Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Version 4.6.85.21 (cherry-pick)
Browse files Browse the repository at this point in the history
Merged 905e008
Merged c1be709
Merged 953024c

Vector ICs: Hook up vectors in platform builtins to their SharedFunctionInfos.

PPC: Vector ICs: Hook up vectors in platform builtins to their SharedFunctionInfos.

X87: Vector ICs: Hook up vectors in platform builtins to their SharedFunctionInfos.

BUG=v8:4423,chromium:534804
LOG=N
R=ulan@chromium.org

Review URL: https://codereview.chromium.org/1363883002 .

Cr-Commit-Position: refs/branch-heads/4.6@{#24}
Cr-Branched-From: 24d34a8-refs/heads/4.6.85@{#1}
Cr-Branched-From: 8f44118-refs/heads/master@{#30256}
  • Loading branch information
ripsawridge committed Sep 23, 2015
1 parent 16d0911 commit 158b345
Show file tree
Hide file tree
Showing 13 changed files with 287 additions and 146 deletions.
2 changes: 1 addition & 1 deletion include/v8-version.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#define V8_MAJOR_VERSION 4
#define V8_MINOR_VERSION 6
#define V8_BUILD_NUMBER 85
#define V8_PATCH_LEVEL 20
#define V8_PATCH_LEVEL 21

// Use 1 for candidates and 0 otherwise.
// (Boolean macro values are not supported by all preprocessors.)
Expand Down
45 changes: 26 additions & 19 deletions src/arm/builtins-arm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1436,6 +1436,7 @@ void Builtins::Generate_FunctionCall(MacroAssembler* masm) {


static void Generate_PushAppliedArguments(MacroAssembler* masm,
const int vectorOffset,
const int argumentsOffset,
const int indexOffset,
const int limitOffset) {
Expand All @@ -1453,13 +1454,9 @@ static void Generate_PushAppliedArguments(MacroAssembler* masm,
__ ldr(receiver, MemOperand(fp, argumentsOffset));

// Use inline caching to speed up access to arguments.
Code::Kind kinds[] = {Code::KEYED_LOAD_IC};
FeedbackVectorSpec spec(0, 1, kinds);
Handle<TypeFeedbackVector> feedback_vector =
masm->isolate()->factory()->NewTypeFeedbackVector(&spec);
int index = feedback_vector->GetIndex(FeedbackVectorICSlot(0));
__ mov(slot, Operand(Smi::FromInt(index)));
__ Move(vector, feedback_vector);
int slot_index = TypeFeedbackVector::PushAppliedArgumentsIndex();
__ mov(slot, Operand(Smi::FromInt(slot_index)));
__ ldr(vector, MemOperand(fp, vectorOffset));
Handle<Code> ic =
KeyedLoadICStub(masm->isolate(), LoadICState(kNoExtraICState)).GetCode();
__ Call(ic, RelocInfo::CODE_TARGET);
Expand Down Expand Up @@ -1494,6 +1491,13 @@ static void Generate_ApplyHelper(MacroAssembler* masm, bool targetIsArgument) {
const int kArgumentsOffset = kFPOnStackSize + kPCOnStackSize;
const int kReceiverOffset = kArgumentsOffset + kPointerSize;
const int kFunctionOffset = kReceiverOffset + kPointerSize;
const int kVectorOffset =
InternalFrameConstants::kCodeOffset - 1 * kPointerSize;

// Push the vector.
__ ldr(r1, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset));
__ ldr(r1, FieldMemOperand(r1, SharedFunctionInfo::kFeedbackVectorOffset));
__ Push(r1);

__ ldr(r0, MemOperand(fp, kFunctionOffset)); // get the function
__ push(r0);
Expand All @@ -1508,10 +1512,8 @@ static void Generate_ApplyHelper(MacroAssembler* masm, bool targetIsArgument) {
Generate_CheckStackOverflow(masm, kFunctionOffset, r0, kArgcIsSmiTagged);

// Push current limit and index.
const int kIndexOffset =
StandardFrameConstants::kExpressionsOffset - (2 * kPointerSize);
const int kLimitOffset =
StandardFrameConstants::kExpressionsOffset - (1 * kPointerSize);
const int kIndexOffset = kVectorOffset - (2 * kPointerSize);
const int kLimitOffset = kVectorOffset - (1 * kPointerSize);
__ push(r0); // limit
__ mov(r1, Operand::Zero()); // initial index
__ push(r1);
Expand Down Expand Up @@ -1574,8 +1576,8 @@ static void Generate_ApplyHelper(MacroAssembler* masm, bool targetIsArgument) {
__ push(r0);

// Copy all arguments from the array to the stack.
Generate_PushAppliedArguments(
masm, kArgumentsOffset, kIndexOffset, kLimitOffset);
Generate_PushAppliedArguments(masm, kVectorOffset, kArgumentsOffset,
kIndexOffset, kLimitOffset);

// Call the function.
Label call_proxy;
Expand Down Expand Up @@ -1614,6 +1616,13 @@ static void Generate_ConstructHelper(MacroAssembler* masm) {
const int kNewTargetOffset = kFPOnStackSize + kPCOnStackSize;
const int kArgumentsOffset = kNewTargetOffset + kPointerSize;
const int kFunctionOffset = kArgumentsOffset + kPointerSize;
static const int kVectorOffset =
InternalFrameConstants::kCodeOffset - 1 * kPointerSize;

// Push the vector.
__ ldr(r1, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset));
__ ldr(r1, FieldMemOperand(r1, SharedFunctionInfo::kFeedbackVectorOffset));
__ Push(r1);

// If newTarget is not supplied, set it to constructor
Label validate_arguments;
Expand All @@ -1636,10 +1645,8 @@ static void Generate_ConstructHelper(MacroAssembler* masm) {
Generate_CheckStackOverflow(masm, kFunctionOffset, r0, kArgcIsSmiTagged);

// Push current limit and index.
const int kIndexOffset =
StandardFrameConstants::kExpressionsOffset - (2 * kPointerSize);
const int kLimitOffset =
StandardFrameConstants::kExpressionsOffset - (1 * kPointerSize);
const int kIndexOffset = kVectorOffset - (2 * kPointerSize);
const int kLimitOffset = kVectorOffset - (1 * kPointerSize);
__ push(r0); // limit
__ mov(r1, Operand::Zero()); // initial index
__ push(r1);
Expand All @@ -1648,8 +1655,8 @@ static void Generate_ConstructHelper(MacroAssembler* masm) {
__ push(r0);

// Copy all arguments from the array to the stack.
Generate_PushAppliedArguments(
masm, kArgumentsOffset, kIndexOffset, kLimitOffset);
Generate_PushAppliedArguments(masm, kVectorOffset, kArgumentsOffset,
kIndexOffset, kLimitOffset);

// Use undefined feedback vector
__ LoadRoot(r2, Heap::kUndefinedValueRootIndex);
Expand Down
56 changes: 36 additions & 20 deletions src/arm64/builtins-arm64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1470,6 +1470,7 @@ void Builtins::Generate_FunctionCall(MacroAssembler* masm) {


static void Generate_PushAppliedArguments(MacroAssembler* masm,
const int vectorOffset,
const int argumentsOffset,
const int indexOffset,
const int limitOffset) {
Expand All @@ -1487,13 +1488,9 @@ static void Generate_PushAppliedArguments(MacroAssembler* masm,
__ Ldr(receiver, MemOperand(fp, argumentsOffset));

// Use inline caching to speed up access to arguments.
Code::Kind kinds[] = {Code::KEYED_LOAD_IC};
FeedbackVectorSpec spec(0, 1, kinds);
Handle<TypeFeedbackVector> feedback_vector =
masm->isolate()->factory()->NewTypeFeedbackVector(&spec);
int index = feedback_vector->GetIndex(FeedbackVectorICSlot(0));
__ Mov(slot, Smi::FromInt(index));
__ Mov(vector, feedback_vector);
int slot_index = TypeFeedbackVector::PushAppliedArgumentsIndex();
__ Mov(slot, Operand(Smi::FromInt(slot_index)));
__ Ldr(vector, MemOperand(fp, vectorOffset));
Handle<Code> ic =
KeyedLoadICStub(masm->isolate(), LoadICState(kNoExtraICState)).GetCode();
__ Call(ic, RelocInfo::CODE_TARGET);
Expand Down Expand Up @@ -1528,14 +1525,24 @@ static void Generate_ApplyHelper(MacroAssembler* masm, bool targetIsArgument) {
const int kArgumentsOffset = kFPOnStackSize + kPCOnStackSize;
const int kReceiverOffset = kArgumentsOffset + kPointerSize;
const int kFunctionOffset = kReceiverOffset + kPointerSize;
const int kIndexOffset =
StandardFrameConstants::kExpressionsOffset - (2 * kPointerSize);
const int kLimitOffset =
StandardFrameConstants::kExpressionsOffset - (1 * kPointerSize);
const int kVectorOffset =
InternalFrameConstants::kCodeOffset - 1 * kPointerSize;
const int kIndexOffset = kVectorOffset - (2 * kPointerSize);
const int kLimitOffset = kVectorOffset - (1 * kPointerSize);

Register args = x12;
Register receiver = x14;
Register function = x15;
Register apply_function = x1;

// Push the vector.
__ Ldr(
apply_function,
FieldMemOperand(apply_function, JSFunction::kSharedFunctionInfoOffset));
__ Ldr(apply_function,
FieldMemOperand(apply_function,
SharedFunctionInfo::kFeedbackVectorOffset));
__ Push(apply_function);

// Get the length of the arguments via a builtin call.
__ Ldr(function, MemOperand(fp, kFunctionOffset));
Expand Down Expand Up @@ -1604,8 +1611,8 @@ static void Generate_ApplyHelper(MacroAssembler* masm, bool targetIsArgument) {
__ Push(receiver);

// Copy all arguments from the array to the stack.
Generate_PushAppliedArguments(
masm, kArgumentsOffset, kIndexOffset, kLimitOffset);
Generate_PushAppliedArguments(masm, kVectorOffset, kArgumentsOffset,
kIndexOffset, kLimitOffset);

// At the end of the loop, the number of arguments is stored in 'current',
// represented as a smi.
Expand Down Expand Up @@ -1648,16 +1655,25 @@ static void Generate_ConstructHelper(MacroAssembler* masm) {
const int kNewTargetOffset = kFPOnStackSize + kPCOnStackSize;
const int kArgumentsOffset = kNewTargetOffset + kPointerSize;
const int kFunctionOffset = kArgumentsOffset + kPointerSize;

const int kIndexOffset =
StandardFrameConstants::kExpressionsOffset - (2 * kPointerSize);
const int kLimitOffset =
StandardFrameConstants::kExpressionsOffset - (1 * kPointerSize);
const int kVectorOffset =
InternalFrameConstants::kCodeOffset - 1 * kPointerSize;
const int kIndexOffset = kVectorOffset - (2 * kPointerSize);
const int kLimitOffset = kVectorOffset - (1 * kPointerSize);

// Is x11 safe to use?
Register newTarget = x11;
Register args = x12;
Register function = x15;
Register construct_function = x1;

// Push the vector.
__ Ldr(construct_function,
FieldMemOperand(construct_function,
JSFunction::kSharedFunctionInfoOffset));
__ Ldr(construct_function,
FieldMemOperand(construct_function,
SharedFunctionInfo::kFeedbackVectorOffset));
__ Push(construct_function);

// If newTarget is not supplied, set it to constructor
Label validate_arguments;
Expand All @@ -1683,8 +1699,8 @@ static void Generate_ConstructHelper(MacroAssembler* masm) {
__ Push(argc, x1, function);

// Copy all arguments from the array to the stack.
Generate_PushAppliedArguments(
masm, kArgumentsOffset, kIndexOffset, kLimitOffset);
Generate_PushAppliedArguments(masm, kVectorOffset, kArgumentsOffset,
kIndexOffset, kLimitOffset);

// Use undefined feedback vector
__ LoadRoot(x2, Heap::kUndefinedValueRootIndex);
Expand Down
6 changes: 6 additions & 0 deletions src/bootstrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1937,12 +1937,16 @@ void Genesis::InitializeGlobal_harmony_reflect() {
MaybeHandle<JSObject>(), Builtins::kReflectApply);
apply->shared()->set_internal_formal_parameter_count(3);
apply->shared()->set_length(3);
apply->shared()->set_feedback_vector(
*TypeFeedbackVector::CreatePushAppliedArgumentsVector(isolate()));

Handle<JSFunction> construct = InstallFunction(
builtins, "$reflectConstruct", JS_OBJECT_TYPE, JSObject::kHeaderSize,
MaybeHandle<JSObject>(), Builtins::kReflectConstruct);
construct->shared()->set_internal_formal_parameter_count(3);
construct->shared()->set_length(2);
construct->shared()->set_feedback_vector(
*TypeFeedbackVector::CreatePushAppliedArgumentsVector(isolate()));

if (!FLAG_harmony_reflect) return;

Expand Down Expand Up @@ -2440,6 +2444,8 @@ bool Genesis::InstallNatives(ContextType context_type) {
Handle<JSFunction> apply =
InstallFunction(proto, "apply", JS_OBJECT_TYPE, JSObject::kHeaderSize,
MaybeHandle<JSObject>(), Builtins::kFunctionApply);
apply->shared()->set_feedback_vector(
*TypeFeedbackVector::CreatePushAppliedArgumentsVector(isolate()));

// Make sure that Function.prototype.call appears to be compiled.
// The code will never be called, but inline caching for call will
Expand Down
39 changes: 24 additions & 15 deletions src/ia32/builtins-ia32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1109,6 +1109,7 @@ void Builtins::Generate_FunctionCall(MacroAssembler* masm) {


static void Generate_PushAppliedArguments(MacroAssembler* masm,
const int vectorOffset,
const int argumentsOffset,
const int indexOffset,
const int limitOffset) {
Expand All @@ -1124,13 +1125,9 @@ static void Generate_PushAppliedArguments(MacroAssembler* masm,
__ mov(receiver, Operand(ebp, argumentsOffset)); // load arguments

// Use inline caching to speed up access to arguments.
Code::Kind kinds[] = {Code::KEYED_LOAD_IC};
FeedbackVectorSpec spec(0, 1, kinds);
Handle<TypeFeedbackVector> feedback_vector =
masm->isolate()->factory()->NewTypeFeedbackVector(&spec);
int index = feedback_vector->GetIndex(FeedbackVectorICSlot(0));
__ mov(slot, Immediate(Smi::FromInt(index)));
__ mov(vector, Immediate(feedback_vector));
int slot_index = TypeFeedbackVector::PushAppliedArgumentsIndex();
__ mov(slot, Immediate(Smi::FromInt(slot_index)));
__ mov(vector, Operand(ebp, vectorOffset));
Handle<Code> ic =
KeyedLoadICStub(masm->isolate(), LoadICState(kNoExtraICState)).GetCode();
__ call(ic, RelocInfo::CODE_TARGET);
Expand Down Expand Up @@ -1178,6 +1175,13 @@ static void Generate_ApplyHelper(MacroAssembler* masm, bool targetIsArgument) {
static const int kArgumentsOffset = kFPOnStackSize + kPCOnStackSize;
static const int kReceiverOffset = kArgumentsOffset + kPointerSize;
static const int kFunctionOffset = kReceiverOffset + kPointerSize;
static const int kVectorOffset =
InternalFrameConstants::kCodeOffset - 1 * kPointerSize;

// Push the vector.
__ mov(edi, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset));
__ mov(edi, FieldOperand(edi, SharedFunctionInfo::kFeedbackVectorOffset));
__ push(edi);

__ push(Operand(ebp, kFunctionOffset)); // push this
__ push(Operand(ebp, kArgumentsOffset)); // push arguments
Expand All @@ -1190,8 +1194,7 @@ static void Generate_ApplyHelper(MacroAssembler* masm, bool targetIsArgument) {
Generate_CheckStackOverflow(masm, kFunctionOffset, kEaxIsSmiTagged);

// Push current index and limit.
const int kLimitOffset =
StandardFrameConstants::kExpressionsOffset - 1 * kPointerSize;
const int kLimitOffset = kVectorOffset - 1 * kPointerSize;
const int kIndexOffset = kLimitOffset - 1 * kPointerSize;
__ push(eax); // limit
__ push(Immediate(0)); // index
Expand Down Expand Up @@ -1252,8 +1255,8 @@ static void Generate_ApplyHelper(MacroAssembler* masm, bool targetIsArgument) {
__ push(ebx);

// Loop over the arguments array, pushing each value to the stack
Generate_PushAppliedArguments(
masm, kArgumentsOffset, kIndexOffset, kLimitOffset);
Generate_PushAppliedArguments(masm, kVectorOffset, kArgumentsOffset,
kIndexOffset, kLimitOffset);

// Call the function.
Label call_proxy;
Expand Down Expand Up @@ -1302,6 +1305,13 @@ static void Generate_ConstructHelper(MacroAssembler* masm) {
static const int kNewTargetOffset = kFPOnStackSize + kPCOnStackSize;
static const int kArgumentsOffset = kNewTargetOffset + kPointerSize;
static const int kFunctionOffset = kArgumentsOffset + kPointerSize;
static const int kVectorOffset =
InternalFrameConstants::kCodeOffset - 1 * kPointerSize;

// Push the vector.
__ mov(edi, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset));
__ mov(edi, FieldOperand(edi, SharedFunctionInfo::kFeedbackVectorOffset));
__ push(edi);

// If newTarget is not supplied, set it to constructor
Label validate_arguments;
Expand All @@ -1321,17 +1331,16 @@ static void Generate_ConstructHelper(MacroAssembler* masm) {
Generate_CheckStackOverflow(masm, kFunctionOffset, kEaxIsSmiTagged);

// Push current index and limit.
const int kLimitOffset =
StandardFrameConstants::kExpressionsOffset - 1 * kPointerSize;
const int kLimitOffset = kVectorOffset - 1 * kPointerSize;
const int kIndexOffset = kLimitOffset - 1 * kPointerSize;
__ Push(eax); // limit
__ push(Immediate(0)); // index
// Push the constructor function as callee.
__ push(Operand(ebp, kFunctionOffset));

// Loop over the arguments array, pushing each value to the stack
Generate_PushAppliedArguments(
masm, kArgumentsOffset, kIndexOffset, kLimitOffset);
Generate_PushAppliedArguments(masm, kVectorOffset, kArgumentsOffset,
kIndexOffset, kLimitOffset);

// Use undefined feedback vector
__ LoadRoot(ebx, Heap::kUndefinedValueRootIndex);
Expand Down
Loading

0 comments on commit 158b345

Please sign in to comment.