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

Side by Side Diff: src/builtins.cc

Issue 1884183002: First version of the new generators implementation. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 4 years, 8 months 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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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.h" 5 #include "src/builtins.h"
6 6
7 #include "src/api-arguments.h" 7 #include "src/api-arguments.h"
8 #include "src/api-natives.h" 8 #include "src/api-natives.h"
9 #include "src/api.h" 9 #include "src/api.h"
10 #include "src/base/once.h" 10 #include "src/base/once.h"
(...skipping 2311 matching lines...) Expand 10 before | Expand all | Expand 10 after
2322 2322
2323 void Generate_GeneratorPrototypeResume( 2323 void Generate_GeneratorPrototypeResume(
2324 CodeStubAssembler* assembler, JSGeneratorObject::ResumeMode resume_mode, 2324 CodeStubAssembler* assembler, JSGeneratorObject::ResumeMode resume_mode,
2325 char const* const method_name) { 2325 char const* const method_name) {
2326 typedef CodeStubAssembler::Label Label; 2326 typedef CodeStubAssembler::Label Label;
2327 typedef compiler::Node Node; 2327 typedef compiler::Node Node;
2328 2328
2329 Node* receiver = assembler->Parameter(0); 2329 Node* receiver = assembler->Parameter(0);
2330 Node* value = assembler->Parameter(1); 2330 Node* value = assembler->Parameter(1);
2331 Node* context = assembler->Parameter(4); 2331 Node* context = assembler->Parameter(4);
2332 Node* zero = assembler->SmiConstant(Smi::FromInt(0)); 2332 Node* closed = assembler->SmiConstant(
2333 Smi::FromInt(JSGeneratorObject::kGeneratorClosed));
2333 2334
2334 // Check if the {receiver} is actually a JSGeneratorObject. 2335 // Check if the {receiver} is actually a JSGeneratorObject.
2335 Label if_receiverisincompatible(assembler, Label::kDeferred); 2336 Label if_receiverisincompatible(assembler, Label::kDeferred);
2336 assembler->GotoIf(assembler->WordIsSmi(receiver), &if_receiverisincompatible); 2337 assembler->GotoIf(assembler->WordIsSmi(receiver), &if_receiverisincompatible);
2337 Node* receiver_instance_type = assembler->LoadInstanceType(receiver); 2338 Node* receiver_instance_type = assembler->LoadInstanceType(receiver);
2338 assembler->GotoUnless(assembler->Word32Equal( 2339 assembler->GotoUnless(assembler->Word32Equal(
2339 receiver_instance_type, 2340 receiver_instance_type,
2340 assembler->Int32Constant(JS_GENERATOR_OBJECT_TYPE)), 2341 assembler->Int32Constant(JS_GENERATOR_OBJECT_TYPE)),
2341 &if_receiverisincompatible); 2342 &if_receiverisincompatible);
2342 2343
2343 // Check if the {receiver} is running or already closed. 2344 // Check if the {receiver} is running or already closed.
2344 Node* receiver_continuation = assembler->LoadObjectField( 2345 Node* receiver_continuation = assembler->LoadObjectField(
2345 receiver, JSGeneratorObject::kContinuationOffset); 2346 receiver, JSGeneratorObject::kContinuationOffset);
2346 Label if_receiverisclosed(assembler, Label::kDeferred), 2347 Label if_receiverisclosed(assembler, Label::kDeferred),
2347 if_receiverisrunning(assembler, Label::kDeferred); 2348 if_receiverisrunning(assembler, Label::kDeferred);
2348 assembler->GotoIf(assembler->SmiEqual(receiver_continuation, zero), 2349 assembler->GotoIf(assembler->SmiEqual(receiver_continuation, closed),
2349 &if_receiverisclosed); 2350 &if_receiverisclosed);
2350 assembler->GotoIf(assembler->SmiLessThan(receiver_continuation, zero), 2351 DCHECK_LT(JSGeneratorObject::kGeneratorExecuting,
2352 JSGeneratorObject::kGeneratorClosed);
2353 assembler->GotoIf(assembler->SmiLessThan(receiver_continuation, closed),
2351 &if_receiverisrunning); 2354 &if_receiverisrunning);
2352 2355
2353 // Resume the {receiver} using our trampoline. 2356 // Resume the {receiver} using our trampoline.
2354 Node* result = assembler->CallStub( 2357 Node* result = assembler->CallStub(
2355 CodeFactory::ResumeGenerator(assembler->isolate()), context, value, 2358 CodeFactory::ResumeGenerator(assembler->isolate()), context, value,
2356 receiver, assembler->SmiConstant(Smi::FromInt(resume_mode))); 2359 receiver, assembler->SmiConstant(Smi::FromInt(resume_mode)));
2357 assembler->Return(result); 2360 assembler->Return(result);
2358 2361
2359 assembler->Bind(&if_receiverisincompatible); 2362 assembler->Bind(&if_receiverisincompatible);
2360 { 2363 {
(...skipping 2938 matching lines...) Expand 10 before | Expand all | Expand 10 after
5299 BUILTIN_LIST_T(DEFINE_BUILTIN_ACCESSOR_T) 5302 BUILTIN_LIST_T(DEFINE_BUILTIN_ACCESSOR_T)
5300 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) 5303 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H)
5301 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) 5304 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A)
5302 #undef DEFINE_BUILTIN_ACCESSOR_C 5305 #undef DEFINE_BUILTIN_ACCESSOR_C
5303 #undef DEFINE_BUILTIN_ACCESSOR_A 5306 #undef DEFINE_BUILTIN_ACCESSOR_A
5304 #undef DEFINE_BUILTIN_ACCESSOR_T 5307 #undef DEFINE_BUILTIN_ACCESSOR_T
5305 #undef DEFINE_BUILTIN_ACCESSOR_H 5308 #undef DEFINE_BUILTIN_ACCESSOR_H
5306 5309
5307 } // namespace internal 5310 } // namespace internal
5308 } // namespace v8 5311 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698