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

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

Issue 2521723003: [promises] Remove IsPromise (Closed)
Patch Set: rebase again 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 | src/debug/mirrors.js » ('j') | 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/builtins/builtins-utils.h" 5 #include "src/builtins/builtins-utils.h"
6 #include "src/builtins/builtins.h" 6 #include "src/builtins/builtins.h"
7 7
8 #include "src/code-factory.h" 8 #include "src/code-factory.h"
9 #include "src/promise-utils.h" 9 #include "src/promise-utils.h"
10 10
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 Node* const context = a.Parameter(3); 212 Node* const context = a.Parameter(3);
213 Node* const native_context = a.LoadNativeContext(context); 213 Node* const native_context = a.LoadNativeContext(context);
214 Node* const promise_fun = 214 Node* const promise_fun =
215 a.LoadContextElement(native_context, Context::PROMISE_FUNCTION_INDEX); 215 a.LoadContextElement(native_context, Context::PROMISE_FUNCTION_INDEX);
216 Node* const initial_map = 216 Node* const initial_map =
217 a.LoadObjectField(promise_fun, JSFunction::kPrototypeOrInitialMapOffset); 217 a.LoadObjectField(promise_fun, JSFunction::kPrototypeOrInitialMapOffset);
218 Node* const instance = a.AllocateJSObjectFromMap(initial_map); 218 Node* const instance = a.AllocateJSObjectFromMap(initial_map);
219 a.Return(instance); 219 a.Return(instance);
220 } 220 }
221 221
222 // TODO(gsathya): Refactor promise.js::IsPromise to use this.
223 void Builtins::Generate_IsPromise(compiler::CodeAssemblerState* state) { 222 void Builtins::Generate_IsPromise(compiler::CodeAssemblerState* state) {
224 CodeStubAssembler a(state); 223 CodeStubAssembler a(state);
225 typedef compiler::Node Node; 224 typedef compiler::Node Node;
226 typedef CodeStubAssembler::Label Label; 225 typedef CodeStubAssembler::Label Label;
227 226
228 Node* const maybe_promise = a.Parameter(1); 227 Node* const maybe_promise = a.Parameter(1);
229 Label if_ispromise(&a), if_isnotpromise(&a, Label::kDeferred); 228 Label if_ispromise(&a), if_isnotpromise(&a, Label::kDeferred);
230 a.GotoIf(a.TaggedIsSmi(maybe_promise), &if_isnotpromise); 229 a.GotoIf(a.TaggedIsSmi(maybe_promise), &if_isnotpromise);
231 230
232 a.Branch(a.HasInstanceType(maybe_promise, JS_PROMISE_TYPE), &if_ispromise, 231 a.Branch(a.HasInstanceType(maybe_promise, JS_PROMISE_TYPE), &if_ispromise,
233 &if_isnotpromise); 232 &if_isnotpromise);
234 233
235 a.Bind(&if_ispromise); 234 a.Bind(&if_ispromise);
236 a.Return(a.BooleanConstant(true)); 235 a.Return(a.BooleanConstant(true));
237 236
238 a.Bind(&if_isnotpromise); 237 a.Bind(&if_isnotpromise);
239 a.Return(a.BooleanConstant(false)); 238 a.Return(a.BooleanConstant(false));
240 } 239 }
241 240
242 } // namespace internal 241 } // namespace internal
243 } // namespace v8 242 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/debug/mirrors.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698