Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(188)

Side by Side Diff: src/promise-utils.cc

Issue 2555023002: Merged: [promises] Set promise context's closure to be an empty function (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/promise-utils.h" 5 #include "src/promise-utils.h"
6 6
7 #include "src/factory.h" 7 #include "src/factory.h"
8 #include "src/isolate.h" 8 #include "src/isolate.h"
9 #include "src/objects-inl.h" 9 #include "src/objects-inl.h"
10 10
(...skipping 26 matching lines...) Expand all
37 void PromiseUtils::CreateResolvingFunctions(Isolate* isolate, 37 void PromiseUtils::CreateResolvingFunctions(Isolate* isolate,
38 Handle<JSObject> promise, 38 Handle<JSObject> promise,
39 Handle<Object> debug_event, 39 Handle<Object> debug_event,
40 Handle<JSFunction>* resolve, 40 Handle<JSFunction>* resolve,
41 Handle<JSFunction>* reject) { 41 Handle<JSFunction>* reject) {
42 DCHECK(debug_event->IsTrue(isolate) || debug_event->IsFalse(isolate)); 42 DCHECK(debug_event->IsTrue(isolate) || debug_event->IsFalse(isolate));
43 Handle<Context> context = 43 Handle<Context> context =
44 isolate->factory()->NewPromiseResolvingFunctionContext( 44 isolate->factory()->NewPromiseResolvingFunctionContext(
45 kPromiseContextLength); 45 kPromiseContextLength);
46 context->set_native_context(*isolate->native_context()); 46 context->set_native_context(*isolate->native_context());
47 // We set the closure to be an empty function, same as native context.
48 context->set_closure(isolate->native_context()->closure());
47 context->set(kAlreadyVisitedSlot, Smi::kZero); 49 context->set(kAlreadyVisitedSlot, Smi::kZero);
48 context->set(kPromiseSlot, *promise); 50 context->set(kPromiseSlot, *promise);
49 context->set(kDebugEventSlot, *debug_event); 51 context->set(kDebugEventSlot, *debug_event);
50 52
51 Handle<SharedFunctionInfo> resolve_shared_fun( 53 Handle<SharedFunctionInfo> resolve_shared_fun(
52 isolate->native_context()->promise_resolve_shared_fun(), isolate); 54 isolate->native_context()->promise_resolve_shared_fun(), isolate);
53 Handle<JSFunction> resolve_fun = 55 Handle<JSFunction> resolve_fun =
54 isolate->factory()->NewFunctionFromSharedFunctionInfo( 56 isolate->factory()->NewFunctionFromSharedFunctionInfo(
55 isolate->sloppy_function_without_prototype_map(), resolve_shared_fun, 57 isolate->sloppy_function_without_prototype_map(), resolve_shared_fun,
56 isolate->native_context(), TENURED); 58 isolate->native_context(), TENURED);
57 59
58 Handle<SharedFunctionInfo> reject_shared_fun( 60 Handle<SharedFunctionInfo> reject_shared_fun(
59 isolate->native_context()->promise_reject_shared_fun(), isolate); 61 isolate->native_context()->promise_reject_shared_fun(), isolate);
60 Handle<JSFunction> reject_fun = 62 Handle<JSFunction> reject_fun =
61 isolate->factory()->NewFunctionFromSharedFunctionInfo( 63 isolate->factory()->NewFunctionFromSharedFunctionInfo(
62 isolate->sloppy_function_without_prototype_map(), reject_shared_fun, 64 isolate->sloppy_function_without_prototype_map(), reject_shared_fun,
63 isolate->native_context(), TENURED); 65 isolate->native_context(), TENURED);
64 66
65 resolve_fun->set_context(*context); 67 resolve_fun->set_context(*context);
66 reject_fun->set_context(*context); 68 reject_fun->set_context(*context);
67 69
68 *resolve = resolve_fun; 70 *resolve = resolve_fun;
69 *reject = reject_fun; 71 *reject = reject_fun;
70 } 72 }
71 73
72 } // namespace internal 74 } // namespace internal
73 } // namespace v8 75 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698