Commit ba41697c authored by gsathya's avatar gsathya Committed by Commit bot

[promises] PromiseResolveThenableJob: change then to be a JSReceiver

BUG=v8:649078

Review-Url: https://codereview.chromium.org/2362503003
Cr-Commit-Position: refs/heads/master@{#39609}
parent a1612d24
...@@ -923,7 +923,7 @@ Handle<Struct> Factory::NewStruct(InstanceType type) { ...@@ -923,7 +923,7 @@ Handle<Struct> Factory::NewStruct(InstanceType type) {
} }
Handle<PromiseContainer> Factory::NewPromiseContainer( Handle<PromiseContainer> Factory::NewPromiseContainer(
Handle<JSReceiver> thenable, Handle<JSFunction> then, Handle<JSReceiver> thenable, Handle<JSReceiver> then,
Handle<JSFunction> resolve, Handle<JSFunction> reject, Handle<JSFunction> resolve, Handle<JSFunction> reject,
Handle<Object> before_debug_event, Handle<Object> after_debug_event) { Handle<Object> before_debug_event, Handle<Object> after_debug_event) {
Handle<PromiseContainer> result = Handle<PromiseContainer> result =
......
...@@ -62,7 +62,7 @@ class Factory final { ...@@ -62,7 +62,7 @@ class Factory final {
// Create a new PromiseContainer struct. // Create a new PromiseContainer struct.
Handle<PromiseContainer> NewPromiseContainer( Handle<PromiseContainer> NewPromiseContainer(
Handle<JSReceiver> thenable, Handle<JSFunction> then, Handle<JSReceiver> thenable, Handle<JSReceiver> then,
Handle<JSFunction> resolve, Handle<JSFunction> reject, Handle<JSFunction> resolve, Handle<JSFunction> reject,
Handle<Object> before_debug_event, Handle<Object> after_debug_event); Handle<Object> before_debug_event, Handle<Object> after_debug_event);
......
...@@ -2981,7 +2981,7 @@ void Isolate::PromiseResolveThenableJob(Handle<PromiseContainer> container, ...@@ -2981,7 +2981,7 @@ void Isolate::PromiseResolveThenableJob(Handle<PromiseContainer> container,
Handle<JSReceiver> thenable(container->thenable(), this); Handle<JSReceiver> thenable(container->thenable(), this);
Handle<JSFunction> resolve(container->resolve(), this); Handle<JSFunction> resolve(container->resolve(), this);
Handle<JSFunction> reject(container->reject(), this); Handle<JSFunction> reject(container->reject(), this);
Handle<JSFunction> then(container->then(), this); Handle<JSReceiver> then(container->then(), this);
Handle<Object> argv[] = {resolve, reject}; Handle<Object> argv[] = {resolve, reject};
*result = Execution::TryCall(this, then, thenable, arraysize(argv), argv, *result = Execution::TryCall(this, then, thenable, arraysize(argv), argv,
maybe_exception); maybe_exception);
...@@ -3057,10 +3057,11 @@ void Isolate::RunMicrotasksInternal() { ...@@ -3057,10 +3057,11 @@ void Isolate::RunMicrotasksInternal() {
callback(data); callback(data);
} else { } else {
SaveContext save(this); SaveContext save(this);
Context* context = Context* context = microtask->IsJSFunction()
microtask->IsJSFunction() ? Handle<JSFunction>::cast(microtask)->context()
? Handle<JSFunction>::cast(microtask)->context() : Handle<PromiseContainer>::cast(microtask)
: Handle<PromiseContainer>::cast(microtask)->then()->context(); ->resolve()
->context();
set_context(context->native_context()); set_context(context->native_context());
handle_scope_implementer_->EnterMicrotaskContext( handle_scope_implementer_->EnterMicrotaskContext(
Handle<Context>(context, this)); Handle<Context>(context, this));
......
...@@ -5655,7 +5655,7 @@ ACCESSORS(AccessorInfo, data, Object, kDataOffset) ...@@ -5655,7 +5655,7 @@ ACCESSORS(AccessorInfo, data, Object, kDataOffset)
ACCESSORS(Box, value, Object, kValueOffset) ACCESSORS(Box, value, Object, kValueOffset)
ACCESSORS(PromiseContainer, thenable, JSReceiver, kThenableOffset) ACCESSORS(PromiseContainer, thenable, JSReceiver, kThenableOffset)
ACCESSORS(PromiseContainer, then, JSFunction, kThenOffset) ACCESSORS(PromiseContainer, then, JSReceiver, kThenOffset)
ACCESSORS(PromiseContainer, resolve, JSFunction, kResolveOffset) ACCESSORS(PromiseContainer, resolve, JSFunction, kResolveOffset)
ACCESSORS(PromiseContainer, reject, JSFunction, kRejectOffset) ACCESSORS(PromiseContainer, reject, JSFunction, kRejectOffset)
ACCESSORS(PromiseContainer, before_debug_event, Object, kBeforeDebugEventOffset) ACCESSORS(PromiseContainer, before_debug_event, Object, kBeforeDebugEventOffset)
......
...@@ -6662,7 +6662,7 @@ class Struct: public HeapObject { ...@@ -6662,7 +6662,7 @@ class Struct: public HeapObject {
class PromiseContainer : public Struct { class PromiseContainer : public Struct {
public: public:
DECL_ACCESSORS(thenable, JSReceiver) DECL_ACCESSORS(thenable, JSReceiver)
DECL_ACCESSORS(then, JSFunction) DECL_ACCESSORS(then, JSReceiver)
DECL_ACCESSORS(resolve, JSFunction) DECL_ACCESSORS(resolve, JSFunction)
DECL_ACCESSORS(reject, JSFunction) DECL_ACCESSORS(reject, JSFunction)
DECL_ACCESSORS(before_debug_event, Object) DECL_ACCESSORS(before_debug_event, Object)
......
...@@ -558,7 +558,7 @@ RUNTIME_FUNCTION(Runtime_EnqueuePromiseResolveThenableJob) { ...@@ -558,7 +558,7 @@ RUNTIME_FUNCTION(Runtime_EnqueuePromiseResolveThenableJob) {
HandleScope scope(isolate); HandleScope scope(isolate);
DCHECK(args.length() == 6); DCHECK(args.length() == 6);
CONVERT_ARG_HANDLE_CHECKED(JSReceiver, resolution, 0); CONVERT_ARG_HANDLE_CHECKED(JSReceiver, resolution, 0);
CONVERT_ARG_HANDLE_CHECKED(JSFunction, then, 1); CONVERT_ARG_HANDLE_CHECKED(JSReceiver, then, 1);
CONVERT_ARG_HANDLE_CHECKED(JSFunction, resolve, 2); CONVERT_ARG_HANDLE_CHECKED(JSFunction, resolve, 2);
CONVERT_ARG_HANDLE_CHECKED(JSFunction, reject, 3); CONVERT_ARG_HANDLE_CHECKED(JSFunction, reject, 3);
CONVERT_ARG_HANDLE_CHECKED(Object, before_debug_event, 4); CONVERT_ARG_HANDLE_CHECKED(Object, before_debug_event, 4);
......
// Copyright 2016 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.
let p = Promise.resolve();
Object.defineProperty(p, 'then', {
get: () => new Proxy(function() {}, p)
});
new Promise((r) => r(p));
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