Commit e1236782 authored by ulan's avatar ulan Committed by Commit bot

Embed store callback in handler via weak cell.

BUG=chromium:454619
LOG=NO

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

Cr-Commit-Position: refs/heads/master@{#26748}
parent e758a36b
...@@ -671,12 +671,21 @@ void NamedLoadHandlerCompiler::GenerateLoadInterceptor(Register holder_reg) { ...@@ -671,12 +671,21 @@ void NamedLoadHandlerCompiler::GenerateLoadInterceptor(Register holder_reg) {
Handle<Code> NamedStoreHandlerCompiler::CompileStoreCallback( Handle<Code> NamedStoreHandlerCompiler::CompileStoreCallback(
Handle<JSObject> object, Handle<Name> name, int accessor_index) { Handle<JSObject> object, Handle<Name> name,
Handle<ExecutableAccessorInfo> callback) {
Register holder_reg = Frontend(name); Register holder_reg = Frontend(name);
__ push(receiver()); // receiver __ push(receiver()); // receiver
__ push(holder_reg); __ push(holder_reg);
__ mov(ip, Operand(Smi::FromInt(accessor_index)));
// If the callback cannot leak, then push the callback directly,
// otherwise wrap it in a weak cell.
if (callback->data()->IsUndefined() || callback->data()->IsSmi()) {
__ mov(ip, Operand(callback));
} else {
Handle<WeakCell> cell = isolate()->factory()->NewWeakCell(callback);
__ mov(ip, Operand(cell));
}
__ push(ip); __ push(ip);
__ mov(ip, Operand(name)); __ mov(ip, Operand(name));
__ Push(ip, value()); __ Push(ip, value());
......
...@@ -735,7 +735,8 @@ void NamedLoadHandlerCompiler::GenerateLoadInterceptor(Register holder_reg) { ...@@ -735,7 +735,8 @@ void NamedLoadHandlerCompiler::GenerateLoadInterceptor(Register holder_reg) {
Handle<Code> NamedStoreHandlerCompiler::CompileStoreCallback( Handle<Code> NamedStoreHandlerCompiler::CompileStoreCallback(
Handle<JSObject> object, Handle<Name> name, int accessor_index) { Handle<JSObject> object, Handle<Name> name,
Handle<ExecutableAccessorInfo> callback) {
ASM_LOCATION("NamedStoreHandlerCompiler::CompileStoreCallback"); ASM_LOCATION("NamedStoreHandlerCompiler::CompileStoreCallback");
Register holder_reg = Frontend(name); Register holder_reg = Frontend(name);
...@@ -745,7 +746,14 @@ Handle<Code> NamedStoreHandlerCompiler::CompileStoreCallback( ...@@ -745,7 +746,14 @@ Handle<Code> NamedStoreHandlerCompiler::CompileStoreCallback(
// receiver() and holder_reg can alias. // receiver() and holder_reg can alias.
DCHECK(!AreAliased(receiver(), scratch1(), scratch2(), value())); DCHECK(!AreAliased(receiver(), scratch1(), scratch2(), value()));
DCHECK(!AreAliased(holder_reg, scratch1(), scratch2(), value())); DCHECK(!AreAliased(holder_reg, scratch1(), scratch2(), value()));
__ Mov(scratch1(), Operand(Smi::FromInt(accessor_index))); // If the callback cannot leak, then push the callback directly,
// otherwise wrap it in a weak cell.
if (callback->data()->IsUndefined() || callback->data()->IsSmi()) {
__ Mov(scratch1(), Operand(callback));
} else {
Handle<WeakCell> cell = isolate()->factory()->NewWeakCell(callback);
__ Mov(scratch1(), Operand(cell));
}
__ Mov(scratch2(), Operand(name)); __ Mov(scratch2(), Operand(name));
__ Push(receiver(), holder_reg, scratch1(), scratch2(), value()); __ Push(receiver(), holder_reg, scratch1(), scratch2(), value());
......
...@@ -223,7 +223,7 @@ class NamedStoreHandlerCompiler : public PropertyHandlerCompiler { ...@@ -223,7 +223,7 @@ class NamedStoreHandlerCompiler : public PropertyHandlerCompiler {
Handle<Name> name); Handle<Name> name);
Handle<Code> CompileStoreField(LookupIterator* it); Handle<Code> CompileStoreField(LookupIterator* it);
Handle<Code> CompileStoreCallback(Handle<JSObject> object, Handle<Name> name, Handle<Code> CompileStoreCallback(Handle<JSObject> object, Handle<Name> name,
int accessor_index); Handle<ExecutableAccessorInfo> callback);
Handle<Code> CompileStoreCallback(Handle<JSObject> object, Handle<Name> name, Handle<Code> CompileStoreCallback(Handle<JSObject> object, Handle<Name> name,
const CallOptimization& call_optimization, const CallOptimization& call_optimization,
int accessor_index); int accessor_index);
......
...@@ -685,13 +685,21 @@ void NamedLoadHandlerCompiler::GenerateLoadInterceptor(Register holder_reg) { ...@@ -685,13 +685,21 @@ void NamedLoadHandlerCompiler::GenerateLoadInterceptor(Register holder_reg) {
Handle<Code> NamedStoreHandlerCompiler::CompileStoreCallback( Handle<Code> NamedStoreHandlerCompiler::CompileStoreCallback(
Handle<JSObject> object, Handle<Name> name, int accessor_index) { Handle<JSObject> object, Handle<Name> name,
Handle<ExecutableAccessorInfo> callback) {
Register holder_reg = Frontend(name); Register holder_reg = Frontend(name);
__ pop(scratch1()); // remove the return address __ pop(scratch1()); // remove the return address
__ push(receiver()); __ push(receiver());
__ push(holder_reg); __ push(holder_reg);
__ Push(Smi::FromInt(accessor_index)); // If the callback cannot leak, then push the callback directly,
// otherwise wrap it in a weak cell.
if (callback->data()->IsUndefined() || callback->data()->IsSmi()) {
__ Push(callback);
} else {
Handle<WeakCell> cell = isolate()->factory()->NewWeakCell(callback);
__ Push(cell);
}
__ Push(name); __ Push(name);
__ push(value()); __ push(value());
__ push(scratch1()); // restore return address __ push(scratch1()); // restore return address
......
...@@ -1690,8 +1690,7 @@ Handle<Code> StoreIC::CompileHandler(LookupIterator* lookup, ...@@ -1690,8 +1690,7 @@ Handle<Code> StoreIC::CompileHandler(LookupIterator* lookup,
break; break;
} }
NamedStoreHandlerCompiler compiler(isolate(), receiver_map(), holder); NamedStoreHandlerCompiler compiler(isolate(), receiver_map(), holder);
return compiler.CompileStoreCallback(receiver, lookup->name(), return compiler.CompileStoreCallback(receiver, lookup->name(), info);
lookup->GetAccessorIndex());
} else if (accessors->IsAccessorPair()) { } else if (accessors->IsAccessorPair()) {
Handle<Object> setter(Handle<AccessorPair>::cast(accessors)->setter(), Handle<Object> setter(Handle<AccessorPair>::cast(accessors)->setter(),
isolate()); isolate());
...@@ -2763,14 +2762,16 @@ RUNTIME_FUNCTION(ToBooleanIC_Miss) { ...@@ -2763,14 +2762,16 @@ RUNTIME_FUNCTION(ToBooleanIC_Miss) {
RUNTIME_FUNCTION(StoreCallbackProperty) { RUNTIME_FUNCTION(StoreCallbackProperty) {
Handle<JSObject> receiver = args.at<JSObject>(0); Handle<JSObject> receiver = args.at<JSObject>(0);
Handle<JSObject> holder = args.at<JSObject>(1); Handle<JSObject> holder = args.at<JSObject>(1);
Handle<Smi> accessor_index = args.at<Smi>(2); Handle<HeapObject> callback_or_cell = args.at<HeapObject>(2);
Handle<Name> name = args.at<Name>(3); Handle<Name> name = args.at<Name>(3);
Handle<Object> value = args.at<Object>(4); Handle<Object> value = args.at<Object>(4);
HandleScope scope(isolate); HandleScope scope(isolate);
Handle<ExecutableAccessorInfo> callback(ExecutableAccessorInfo::cast( Handle<ExecutableAccessorInfo> callback(
holder->map()->instance_descriptors()->GetCallbacksObject( callback_or_cell->IsWeakCell()
accessor_index->value()))); ? ExecutableAccessorInfo::cast(
WeakCell::cast(*callback_or_cell)->value())
: ExecutableAccessorInfo::cast(*callback_or_cell));
DCHECK(callback->IsCompatibleReceiver(*receiver)); DCHECK(callback->IsCompatibleReceiver(*receiver));
......
...@@ -662,11 +662,19 @@ void NamedLoadHandlerCompiler::GenerateLoadInterceptor(Register holder_reg) { ...@@ -662,11 +662,19 @@ void NamedLoadHandlerCompiler::GenerateLoadInterceptor(Register holder_reg) {
Handle<Code> NamedStoreHandlerCompiler::CompileStoreCallback( Handle<Code> NamedStoreHandlerCompiler::CompileStoreCallback(
Handle<JSObject> object, Handle<Name> name, int accessor_index) { Handle<JSObject> object, Handle<Name> name,
Handle<ExecutableAccessorInfo> callback) {
Register holder_reg = Frontend(name); Register holder_reg = Frontend(name);
__ Push(receiver(), holder_reg); // Receiver. __ Push(receiver(), holder_reg); // Receiver.
__ li(at, Operand(Smi::FromInt(accessor_index))); // If the callback cannot leak, then push the callback directly,
// otherwise wrap it in a weak cell.
if (callback->data()->IsUndefined() || callback->data()->IsSmi()) {
__ li(at, Operand(callback));
} else {
Handle<WeakCell> cell = isolate()->factory()->NewWeakCell(callback);
__ li(at, Operand(cell));
}
__ push(at); __ push(at);
__ li(at, Operand(name)); __ li(at, Operand(name));
__ Push(at, value()); __ Push(at, value());
......
...@@ -663,11 +663,19 @@ void NamedLoadHandlerCompiler::GenerateLoadInterceptor(Register holder_reg) { ...@@ -663,11 +663,19 @@ void NamedLoadHandlerCompiler::GenerateLoadInterceptor(Register holder_reg) {
Handle<Code> NamedStoreHandlerCompiler::CompileStoreCallback( Handle<Code> NamedStoreHandlerCompiler::CompileStoreCallback(
Handle<JSObject> object, Handle<Name> name, int accessor_index) { Handle<JSObject> object, Handle<Name> name,
Handle<ExecutableAccessorInfo> callback) {
Register holder_reg = Frontend(name); Register holder_reg = Frontend(name);
__ Push(receiver(), holder_reg); // Receiver. __ Push(receiver(), holder_reg); // Receiver.
__ li(at, Operand(Smi::FromInt(accessor_index))); // If the callback cannot leak, then push the callback directly,
// otherwise wrap it in a weak cell.
if (callback->data()->IsUndefined() || callback->data()->IsSmi()) {
__ li(at, Operand(callback));
} else {
Handle<WeakCell> cell = isolate()->factory()->NewWeakCell(callback);
__ li(at, Operand(cell));
}
__ push(at); __ push(at);
__ li(at, Operand(name)); __ li(at, Operand(name));
__ Push(at, value()); __ Push(at, value());
......
...@@ -676,13 +676,21 @@ void NamedLoadHandlerCompiler::GenerateLoadInterceptor(Register holder_reg) { ...@@ -676,13 +676,21 @@ void NamedLoadHandlerCompiler::GenerateLoadInterceptor(Register holder_reg) {
Handle<Code> NamedStoreHandlerCompiler::CompileStoreCallback( Handle<Code> NamedStoreHandlerCompiler::CompileStoreCallback(
Handle<JSObject> object, Handle<Name> name, int accessor_index) { Handle<JSObject> object, Handle<Name> name,
Handle<ExecutableAccessorInfo> callback) {
Register holder_reg = Frontend(name); Register holder_reg = Frontend(name);
__ PopReturnAddressTo(scratch1()); __ PopReturnAddressTo(scratch1());
__ Push(receiver()); __ Push(receiver());
__ Push(holder_reg); __ Push(holder_reg);
__ Push(Smi::FromInt(accessor_index)); // If the callback cannot leak, then push the callback directly,
// otherwise wrap it in a weak cell.
if (callback->data()->IsUndefined() || callback->data()->IsSmi()) {
__ Push(callback);
} else {
Handle<WeakCell> cell = isolate()->factory()->NewWeakCell(callback);
__ Push(cell);
}
__ Push(name); __ Push(name);
__ Push(value()); __ Push(value());
__ PushReturnAddressFrom(scratch1()); __ PushReturnAddressFrom(scratch1());
......
...@@ -687,13 +687,21 @@ void NamedLoadHandlerCompiler::GenerateLoadInterceptor(Register holder_reg) { ...@@ -687,13 +687,21 @@ void NamedLoadHandlerCompiler::GenerateLoadInterceptor(Register holder_reg) {
Handle<Code> NamedStoreHandlerCompiler::CompileStoreCallback( Handle<Code> NamedStoreHandlerCompiler::CompileStoreCallback(
Handle<JSObject> object, Handle<Name> name, int accessor_index) { Handle<JSObject> object, Handle<Name> name,
Handle<ExecutableAccessorInfo> callback) {
Register holder_reg = Frontend(name); Register holder_reg = Frontend(name);
__ pop(scratch1()); // remove the return address __ pop(scratch1()); // remove the return address
__ push(receiver()); __ push(receiver());
__ push(holder_reg); __ push(holder_reg);
__ Push(Smi::FromInt(accessor_index)); // If the callback cannot leak, then push the callback directly,
// otherwise wrap it in a weak cell.
if (callback->data()->IsUndefined() || callback->data()->IsSmi()) {
__ Push(callback);
} else {
Handle<WeakCell> cell = isolate()->factory()->NewWeakCell(callback);
__ Push(cell);
}
__ Push(name); __ Push(name);
__ push(value()); __ push(value());
__ push(scratch1()); // restore return address __ push(scratch1()); // restore return address
......
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