Skip to content

Commit 07de62c

Browse files
verwaestCommit Bot
authored andcommitted
[lazy-accessor-pairs] Don't take the fast paths if the context needs to be switched
(This is a reland of cb84b6f) This works in the ICs since compiled handlers are not shared anymore. Bug: chromium:759734 Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng Change-Id: I3b7d6ae34bb4cfa213f679354fac56fb51bfd5ed Reviewed-on: https://chromium-review.googlesource.com/739822 Reviewed-by: Igor Sheludko <ishell@chromium.org> Reviewed-by: Benedikt Meurer <bmeurer@chromium.org> Commit-Queue: Toon Verwaest <verwaest@chromium.org> Cr-Commit-Position: refs/heads/master@{#48999}
1 parent 17a9caf commit 07de62c

43 files changed

Lines changed: 204 additions & 656 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

include/v8.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3735,7 +3735,7 @@ class FunctionCallbackInfo {
37353735
/** The ReturnValue for the call. */
37363736
V8_INLINE ReturnValue<T> GetReturnValue() const;
37373737
// This shouldn't be public, but the arm compiler needs it.
3738-
static const int kArgsLength = 8;
3738+
static const int kArgsLength = 7;
37393739

37403740
protected:
37413741
friend class internal::FunctionCallbackArguments;
@@ -3747,8 +3747,7 @@ class FunctionCallbackInfo {
37473747
static const int kReturnValueIndex = 3;
37483748
static const int kDataIndex = 4;
37493749
static const int kCalleeIndex = 5;
3750-
static const int kContextSaveIndex = 6;
3751-
static const int kNewTargetIndex = 7;
3750+
static const int kNewTargetIndex = 6;
37523751

37533752
V8_INLINE FunctionCallbackInfo(internal::Object** implicit_args,
37543753
internal::Object** values, int length);

src/api-arguments.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ class FunctionCallbackArguments
159159
T::kReturnValueDefaultValueIndex;
160160
static const int kIsolateIndex = T::kIsolateIndex;
161161
static const int kCalleeIndex = T::kCalleeIndex;
162-
static const int kContextSaveIndex = T::kContextSaveIndex;
163162
static const int kNewTargetIndex = T::kNewTargetIndex;
164163

165164
FunctionCallbackArguments(internal::Isolate* isolate, internal::Object* data,
@@ -173,7 +172,6 @@ class FunctionCallbackArguments
173172
values[T::kCalleeIndex] = callee;
174173
values[T::kHolderIndex] = holder;
175174
values[T::kNewTargetIndex] = new_target;
176-
values[T::kContextSaveIndex] = isolate->heap()->the_hole_value();
177175
values[T::kIsolateIndex] = reinterpret_cast<internal::Object*>(isolate);
178176
// Here the hole is set as default value.
179177
// It cannot escape into js as it's remove in Call below.

src/arm/code-stubs-arm.cc

Lines changed: 9 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ void CEntryStub::Generate(MacroAssembler* masm) {
376376
? no_reg
377377
// Callee-saved register r4 still holds argc.
378378
: r4;
379-
__ LeaveExitFrame(save_doubles(), argc, true);
379+
__ LeaveExitFrame(save_doubles(), argc);
380380
__ mov(pc, lr);
381381

382382
// Handling of exception.
@@ -1347,8 +1347,7 @@ static void CallApiFunctionAndReturn(MacroAssembler* masm,
13471347
ExternalReference thunk_ref,
13481348
int stack_space,
13491349
MemOperand* stack_space_operand,
1350-
MemOperand return_value_operand,
1351-
MemOperand* context_restore_operand) {
1350+
MemOperand return_value_operand) {
13521351
Isolate* isolate = masm->isolate();
13531352
ExternalReference next_address =
13541353
ExternalReference::handle_scope_next_address(isolate);
@@ -1433,18 +1432,13 @@ static void CallApiFunctionAndReturn(MacroAssembler* masm,
14331432

14341433
// Leave the API exit frame.
14351434
__ bind(&leave_exit_frame);
1436-
bool restore_context = context_restore_operand != nullptr;
1437-
if (restore_context) {
1438-
__ ldr(cp, *context_restore_operand);
1439-
}
14401435
// LeaveExitFrame expects unwind space to be in a register.
14411436
if (stack_space_operand != nullptr) {
14421437
__ ldr(r4, *stack_space_operand);
14431438
} else {
14441439
__ mov(r4, Operand(stack_space));
14451440
}
1446-
__ LeaveExitFrame(false, r4, !restore_context,
1447-
stack_space_operand != nullptr);
1441+
__ LeaveExitFrame(false, r4, stack_space_operand != nullptr);
14481442

14491443
// Check if the function scheduled an exception.
14501444
__ LoadRoot(r4, Heap::kTheHoleValueRootIndex);
@@ -1483,7 +1477,6 @@ void CallApiCallbackStub::Generate(MacroAssembler* masm) {
14831477
// -- ...
14841478
// -- sp[(argc - 1) * 4] : first argument
14851479
// -- sp[argc * 4] : receiver
1486-
// -- sp[(argc + 1) * 4] : accessor_holder
14871480
// -----------------------------------
14881481

14891482
Register callee = r0;
@@ -1494,9 +1487,8 @@ void CallApiCallbackStub::Generate(MacroAssembler* masm) {
14941487

14951488
typedef FunctionCallbackArguments FCA;
14961489

1497-
STATIC_ASSERT(FCA::kArgsLength == 8);
1498-
STATIC_ASSERT(FCA::kNewTargetIndex == 7);
1499-
STATIC_ASSERT(FCA::kContextSaveIndex == 6);
1490+
STATIC_ASSERT(FCA::kArgsLength == 7);
1491+
STATIC_ASSERT(FCA::kNewTargetIndex == 6);
15001492
STATIC_ASSERT(FCA::kCalleeIndex == 5);
15011493
STATIC_ASSERT(FCA::kDataIndex == 4);
15021494
STATIC_ASSERT(FCA::kReturnValueOffset == 3);
@@ -1507,9 +1499,6 @@ void CallApiCallbackStub::Generate(MacroAssembler* masm) {
15071499
// new target
15081500
__ PushRoot(Heap::kUndefinedValueRootIndex);
15091501

1510-
// context save
1511-
__ push(context);
1512-
15131502
// callee
15141503
__ push(callee);
15151504

@@ -1531,32 +1520,7 @@ void CallApiCallbackStub::Generate(MacroAssembler* masm) {
15311520
__ push(holder);
15321521

15331522
// enter a new context
1534-
if (is_lazy()) {
1535-
// ----------- S t a t e -------------------------------------
1536-
// -- sp[0] : holder
1537-
// -- ...
1538-
// -- sp[(FCA::kArgsLength - 1) * 4] : new_target
1539-
// -- sp[FCA::kArgsLength * 4] : last argument
1540-
// -- ...
1541-
// -- sp[(FCA::kArgsLength + argc - 1) * 4] : first argument
1542-
// -- sp[(FCA::kArgsLength + argc) * 4] : receiver
1543-
// -- sp[(FCA::kArgsLength + argc + 1) * 4] : accessor_holder
1544-
// -----------------------------------------------------------
1545-
1546-
// load context from accessor_holder
1547-
Register accessor_holder = context;
1548-
__ ldr(accessor_holder,
1549-
MemOperand(sp, (FCA::kArgsLength + 1 + argc()) * kPointerSize));
1550-
// Look for the constructor if |accessor_holder| is not a function.
1551-
Label skip_looking_for_constructor;
1552-
__ ldr(scratch0, FieldMemOperand(accessor_holder, HeapObject::kMapOffset));
1553-
__ ldrb(scratch1, FieldMemOperand(scratch0, Map::kBitFieldOffset));
1554-
__ tst(scratch1, Operand(1 << Map::kIsConstructor));
1555-
__ b(ne, &skip_looking_for_constructor);
1556-
__ GetMapConstructor(context, scratch0, scratch0, scratch1);
1557-
__ bind(&skip_looking_for_constructor);
1558-
__ ldr(context, FieldMemOperand(context, JSFunction::kContextOffset));
1559-
} else {
1523+
if (!is_lazy()) {
15601524
// load context from callee
15611525
__ ldr(context, FieldMemOperand(callee, JSFunction::kContextOffset));
15621526
}
@@ -1589,8 +1553,6 @@ void CallApiCallbackStub::Generate(MacroAssembler* masm) {
15891553
ExternalReference::invoke_function_callback(masm->isolate());
15901554

15911555
AllowExternalCallThatCantCauseGC scope(masm);
1592-
MemOperand context_restore_operand(
1593-
fp, (2 + FCA::kContextSaveIndex) * kPointerSize);
15941556
// Stores return the first js argument
15951557
int return_value_offset = 0;
15961558
if (is_store()) {
@@ -1599,12 +1561,11 @@ void CallApiCallbackStub::Generate(MacroAssembler* masm) {
15991561
return_value_offset = 2 + FCA::kReturnValueOffset;
16001562
}
16011563
MemOperand return_value_operand(fp, return_value_offset * kPointerSize);
1602-
const int stack_space = argc() + FCA::kArgsLength + 2;
1564+
const int stack_space = argc() + FCA::kArgsLength + 1;
16031565
MemOperand* stack_space_operand = nullptr;
16041566

16051567
CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, stack_space,
1606-
stack_space_operand, return_value_operand,
1607-
&context_restore_operand);
1568+
stack_space_operand, return_value_operand);
16081569
}
16091570

16101571

@@ -1666,8 +1627,7 @@ void CallApiGetterStub::Generate(MacroAssembler* masm) {
16661627
MemOperand return_value_operand(
16671628
fp, (PropertyCallbackArguments::kReturnValueOffset + 3) * kPointerSize);
16681629
CallApiFunctionAndReturn(masm, api_function_address, thunk_ref,
1669-
kStackUnwindSpace, nullptr, return_value_operand,
1670-
nullptr);
1630+
kStackUnwindSpace, nullptr, return_value_operand);
16711631
}
16721632

16731633
#undef __

src/arm/macro-assembler-arm.cc

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,7 +1267,6 @@ int TurboAssembler::ActivationFrameAlignment() {
12671267

12681268

12691269
void MacroAssembler::LeaveExitFrame(bool save_doubles, Register argument_count,
1270-
bool restore_context,
12711270
bool argument_count_is_length) {
12721271
ConstantPoolUnavailableScope constant_pool_unavailable(this);
12731272
UseScratchRegisterScope temps(this);
@@ -1288,11 +1287,9 @@ void MacroAssembler::LeaveExitFrame(bool save_doubles, Register argument_count,
12881287
str(r3, MemOperand(scratch));
12891288

12901289
// Restore current context from top and clear it in debug mode.
1291-
if (restore_context) {
1292-
mov(scratch, Operand(ExternalReference(IsolateAddressId::kContextAddress,
1293-
isolate())));
1294-
ldr(cp, MemOperand(scratch));
1295-
}
1290+
mov(scratch,
1291+
Operand(ExternalReference(IsolateAddressId::kContextAddress, isolate())));
1292+
ldr(cp, MemOperand(scratch));
12961293
#ifdef DEBUG
12971294
mov(scratch,
12981295
Operand(ExternalReference(IsolateAddressId::kContextAddress, isolate())));
@@ -1656,19 +1653,6 @@ void MacroAssembler::LoadWeakValue(Register value, Handle<WeakCell> cell,
16561653
JumpIfSmi(value, miss);
16571654
}
16581655

1659-
void MacroAssembler::GetMapConstructor(Register result, Register map,
1660-
Register temp, Register temp2) {
1661-
Label done, loop;
1662-
ldr(result, FieldMemOperand(map, Map::kConstructorOrBackPointerOffset));
1663-
bind(&loop);
1664-
JumpIfSmi(result, &done);
1665-
CompareObjectType(result, temp, temp2, MAP_TYPE);
1666-
b(ne, &done);
1667-
ldr(result, FieldMemOperand(result, Map::kConstructorOrBackPointerOffset));
1668-
b(&loop);
1669-
bind(&done);
1670-
}
1671-
16721656
void MacroAssembler::CallStub(CodeStub* stub,
16731657
Condition cond) {
16741658
DCHECK(AllowThisStubCall(stub)); // Stub calls are not allowed in some stubs.

src/arm/macro-assembler-arm.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,6 @@ class MacroAssembler : public TurboAssembler {
680680
// Expect the number of values, pushed prior to the exit frame, to
681681
// remove in a register (or no_reg, if there is nothing to remove).
682682
void LeaveExitFrame(bool save_doubles, Register argument_count,
683-
bool restore_context,
684683
bool argument_count_is_length = false);
685684

686685
// Load the global proxy from the current context.
@@ -730,11 +729,6 @@ class MacroAssembler : public TurboAssembler {
730729
// ---------------------------------------------------------------------------
731730
// Support functions.
732731

733-
// Machine code version of Map::GetConstructor().
734-
// |temp| holds |result|'s map when done, and |temp2| its instance type.
735-
void GetMapConstructor(Register result, Register map, Register temp,
736-
Register temp2);
737-
738732
// Compare object type for heap object. heap_object contains a non-Smi
739733
// whose object type should be compared with the given type. This both
740734
// sets the flags and leaves the object type in the type_reg register.

src/arm64/code-stubs-arm64.cc

Lines changed: 19 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ void CEntryStub::Generate(MacroAssembler* masm) {
461461
__ Peek(argc, 2 * kPointerSize);
462462
__ Peek(target, 3 * kPointerSize);
463463

464-
__ LeaveExitFrame(save_doubles(), x10, true);
464+
__ LeaveExitFrame(save_doubles(), x10);
465465
DCHECK(jssp.Is(__ StackPointer()));
466466
if (!argv_in_register()) {
467467
// Drop the remaining stack slots and return from the stub.
@@ -1558,8 +1558,7 @@ static void CallApiFunctionAndReturn(MacroAssembler* masm,
15581558
Register function_address,
15591559
ExternalReference thunk_ref,
15601560
int stack_space, int spill_offset,
1561-
MemOperand return_value_operand,
1562-
MemOperand* context_restore_operand) {
1561+
MemOperand return_value_operand) {
15631562
ASM_LOCATION("CallApiFunctionAndReturn");
15641563
Isolate* isolate = masm->isolate();
15651564
ExternalReference next_address =
@@ -1661,12 +1660,7 @@ static void CallApiFunctionAndReturn(MacroAssembler* masm,
16611660
__ Peek(x21, (spill_offset + 2) * kXRegSize);
16621661
__ Peek(x22, (spill_offset + 3) * kXRegSize);
16631662

1664-
bool restore_context = context_restore_operand != nullptr;
1665-
if (restore_context) {
1666-
__ Ldr(cp, *context_restore_operand);
1667-
}
1668-
1669-
__ LeaveExitFrame(false, x1, !restore_context);
1663+
__ LeaveExitFrame(false, x1);
16701664

16711665
// Check if the function scheduled an exception.
16721666
__ Mov(x5, ExternalReference::scheduled_exception_address(isolate));
@@ -1706,7 +1700,6 @@ void CallApiCallbackStub::Generate(MacroAssembler* masm) {
17061700
// -- ...
17071701
// -- sp[(argc - 1) * 8] : first argument
17081702
// -- sp[argc * 8] : receiver
1709-
// -- sp[(argc + 1) * 8] : accessor_holder
17101703
// -----------------------------------
17111704

17121705
Register callee = x0;
@@ -1717,9 +1710,8 @@ void CallApiCallbackStub::Generate(MacroAssembler* masm) {
17171710

17181711
typedef FunctionCallbackArguments FCA;
17191712

1720-
STATIC_ASSERT(FCA::kArgsLength == 8);
1721-
STATIC_ASSERT(FCA::kNewTargetIndex == 7);
1722-
STATIC_ASSERT(FCA::kContextSaveIndex == 6);
1713+
STATIC_ASSERT(FCA::kArgsLength == 7);
1714+
STATIC_ASSERT(FCA::kNewTargetIndex == 6);
17231715
STATIC_ASSERT(FCA::kCalleeIndex == 5);
17241716
STATIC_ASSERT(FCA::kDataIndex == 4);
17251717
STATIC_ASSERT(FCA::kReturnValueOffset == 3);
@@ -1730,8 +1722,8 @@ void CallApiCallbackStub::Generate(MacroAssembler* masm) {
17301722
Register undef = x7;
17311723
__ LoadRoot(undef, Heap::kUndefinedValueRootIndex);
17321724

1733-
// Push new target, context, callee and call data.
1734-
__ Push(undef, context, callee, call_data);
1725+
// Push alignment filler, new target, callee and call data.
1726+
__ Push(undef, undef, callee, call_data);
17351727

17361728
Register isolate_reg = x5;
17371729
__ Mov(isolate_reg, ExternalReference::isolate_address(masm->isolate()));
@@ -1741,35 +1733,7 @@ void CallApiCallbackStub::Generate(MacroAssembler* masm) {
17411733
__ Push(undef, undef, isolate_reg, holder);
17421734

17431735
// Enter a new context.
1744-
if (is_lazy()) {
1745-
// ----------- S t a t e -------------------------------------
1746-
// -- sp[0] : holder
1747-
// -- ...
1748-
// -- sp[(FCA::kArgsLength - 1) * 8] : new_target
1749-
// -- sp[FCA::kArgsLength * 8] : last argument
1750-
// -- ...
1751-
// -- sp[(FCA::kArgsLength + argc - 1) * 8] : first argument
1752-
// -- sp[(FCA::kArgsLength + argc) * 8] : receiver
1753-
// -- sp[(FCA::kArgsLength + argc + 1) * 8] : accessor_holder
1754-
// -----------------------------------------------------------
1755-
1756-
// Load context from accessor_holder.
1757-
Register accessor_holder = context;
1758-
Register scratch = undef;
1759-
Register scratch2 = callee;
1760-
__ Ldr(accessor_holder,
1761-
MemOperand(__ StackPointer(),
1762-
(FCA::kArgsLength + 1 + argc()) * kPointerSize));
1763-
// Look for the constructor if |accessor_holder| is not a function.
1764-
Label skip_looking_for_constructor;
1765-
__ Ldr(scratch, FieldMemOperand(accessor_holder, HeapObject::kMapOffset));
1766-
__ Ldrb(scratch2, FieldMemOperand(scratch, Map::kBitFieldOffset));
1767-
__ Tst(scratch2, Operand(1 << Map::kIsConstructor));
1768-
__ B(ne, &skip_looking_for_constructor);
1769-
__ GetMapConstructor(context, scratch, scratch, scratch2);
1770-
__ Bind(&skip_looking_for_constructor);
1771-
__ Ldr(context, FieldMemOperand(context, JSFunction::kContextOffset));
1772-
} else {
1736+
if (!is_lazy()) {
17731737
// Load context from callee.
17741738
__ Ldr(context, FieldMemOperand(callee, JSFunction::kContextOffset));
17751739
}
@@ -1794,7 +1758,9 @@ void CallApiCallbackStub::Generate(MacroAssembler* masm) {
17941758
// Arguments is after the return address.
17951759
__ SlotAddress(x0, 1);
17961760
// FunctionCallbackInfo::implicit_args_ and FunctionCallbackInfo::values_
1797-
__ Add(x10, args, Operand((FCA::kArgsLength - 1 + argc()) * kPointerSize));
1761+
// + 1 to account for the alignment filler.
1762+
__ Add(x10, args,
1763+
Operand((FCA::kArgsLength - 1 + argc() + 1) * kPointerSize));
17981764
__ Stp(args, x10, MemOperand(x0, 0 * kPointerSize));
17991765
// FunctionCallbackInfo::length_ = argc
18001766
__ Mov(x10, argc());
@@ -1804,8 +1770,6 @@ void CallApiCallbackStub::Generate(MacroAssembler* masm) {
18041770
ExternalReference::invoke_function_callback(masm->isolate());
18051771

18061772
AllowExternalCallThatCantCauseGC scope(masm);
1807-
MemOperand context_restore_operand(
1808-
fp, (2 + FCA::kContextSaveIndex) * kPointerSize);
18091773
// Stores return the first js argument
18101774
int return_value_offset = 0;
18111775
if (is_store()) {
@@ -1815,14 +1779,15 @@ void CallApiCallbackStub::Generate(MacroAssembler* masm) {
18151779
}
18161780
MemOperand return_value_operand(fp, return_value_offset * kPointerSize);
18171781
// The number of arguments might be odd, but will be padded when calling the
1818-
// stub. We do not round up stack_space here, this will be done in
1819-
// CallApiFunctionAndReturn.
1820-
const int stack_space = argc() + FCA::kArgsLength + 2;
1821-
DCHECK_EQ((stack_space - argc()) % 2, 0);
1782+
// stub. We do not round up stack_space to account for odd argc here, this
1783+
// will be done in CallApiFunctionAndReturn. The current frame needs to be
1784+
// aligned here, which is why we push a filler before FCA.
1785+
const int stack_space = (argc() + 1) + FCA::kArgsLength + 1;
1786+
1787+
DCHECK_EQ((stack_space - (argc() + 1)) % 2, 0);
18221788
const int spill_offset = 1 + kApiStackSpace;
18231789
CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, stack_space,
1824-
spill_offset, return_value_operand,
1825-
&context_restore_operand);
1790+
spill_offset, return_value_operand);
18261791
}
18271792

18281793

@@ -1899,7 +1864,7 @@ void CallApiGetterStub::Generate(MacroAssembler* masm) {
18991864
fp, (PropertyCallbackArguments::kReturnValueOffset + 3) * kPointerSize);
19001865
CallApiFunctionAndReturn(masm, api_function_address, thunk_ref,
19011866
kStackUnwindSpace, spill_offset,
1902-
return_value_operand, nullptr);
1867+
return_value_operand);
19031868
}
19041869

19051870
#undef __

0 commit comments

Comments
 (0)