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

Side by Side Diff: src/factory.cc

Issue 13542002: Calling a generator function returns a generator object (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Link generator iterator definitions and uses through local variable Created 7 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
« no previous file with comments | « src/factory.h ('k') | src/full-codegen.cc » ('j') | src/objects.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 607
608 if (function_info->ic_age() != isolate()->heap()->global_ic_age()) { 608 if (function_info->ic_age() != isolate()->heap()->global_ic_age()) {
609 function_info->ResetForNewContext(isolate()->heap()->global_ic_age()); 609 function_info->ResetForNewContext(isolate()->heap()->global_ic_age());
610 } 610 }
611 611
612 result->set_context(*context); 612 result->set_context(*context);
613 613
614 if (function_info->is_generator()) { 614 if (function_info->is_generator()) {
615 // Generator functions have specialized prototypes and instance types, so 615 // Generator functions have specialized prototypes and instance types, so
616 // they need their prototypes to be created eagerly. 616 // they need their prototypes to be created eagerly.
617 // TODO(wingo): Use JS_GENERATOR_TYPE. 617 Handle<Map> instance_map =
618 Handle<Map> instance_map = NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); 618 NewMap(JS_GENERATOR_ITERATOR_TYPE, JSGeneratorIterator::kSize);
619 Handle<JSObject> iterator_prototype = NewFunctionPrototype(result); 619 Handle<JSObject> iterator_prototype = NewFunctionPrototype(result);
620 instance_map->set_prototype(*iterator_prototype); 620 instance_map->set_prototype(*iterator_prototype);
621 result->set_initial_map(*instance_map); 621 result->set_initial_map(*instance_map);
622 } 622 }
623 623
624 int index = function_info->SearchOptimizedCodeMap(context->native_context()); 624 int index = function_info->SearchOptimizedCodeMap(context->native_context());
625 if (!function_info->bound() && index < 0) { 625 if (!function_info->bound() && index < 0) {
626 int number_of_literals = function_info->num_literals(); 626 int number_of_literals = function_info->num_literals();
627 Handle<FixedArray> literals = NewFixedArray(number_of_literals, pretenure); 627 Handle<FixedArray> literals = NewFixedArray(number_of_literals, pretenure);
628 if (number_of_literals > 0) { 628 if (number_of_literals > 0) {
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 971
972 972
973 Handle<JSObject> Factory::NewJSObject(Handle<JSFunction> constructor, 973 Handle<JSObject> Factory::NewJSObject(Handle<JSFunction> constructor,
974 PretenureFlag pretenure) { 974 PretenureFlag pretenure) {
975 CALL_HEAP_FUNCTION( 975 CALL_HEAP_FUNCTION(
976 isolate(), 976 isolate(),
977 isolate()->heap()->AllocateJSObject(*constructor, pretenure), JSObject); 977 isolate()->heap()->AllocateJSObject(*constructor, pretenure), JSObject);
978 } 978 }
979 979
980 980
981 Handle<JSGeneratorIterator> Factory::NewJSGeneratorIterator(
982 Handle<JSFunction> function) {
983 CALL_HEAP_FUNCTION(
984 isolate(),
985 isolate()->heap()->AllocateJSGeneratorIterator(*function),
986 JSGeneratorIterator);
987 }
988
989
981 Handle<JSModule> Factory::NewJSModule(Handle<Context> context, 990 Handle<JSModule> Factory::NewJSModule(Handle<Context> context,
982 Handle<ScopeInfo> scope_info) { 991 Handle<ScopeInfo> scope_info) {
983 CALL_HEAP_FUNCTION( 992 CALL_HEAP_FUNCTION(
984 isolate(), 993 isolate(),
985 isolate()->heap()->AllocateJSModule(*context, *scope_info), JSModule); 994 isolate()->heap()->AllocateJSModule(*context, *scope_info), JSModule);
986 } 995 }
987 996
988 997
989 Handle<GlobalObject> Factory::NewGlobalObject( 998 Handle<GlobalObject> Factory::NewGlobalObject(
990 Handle<JSFunction> constructor) { 999 Handle<JSFunction> constructor) {
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
1505 return Handle<Object>::null(); 1514 return Handle<Object>::null();
1506 } 1515 }
1507 1516
1508 1517
1509 Handle<Object> Factory::ToBoolean(bool value) { 1518 Handle<Object> Factory::ToBoolean(bool value) {
1510 return value ? true_value() : false_value(); 1519 return value ? true_value() : false_value();
1511 } 1520 }
1512 1521
1513 1522
1514 } } // namespace v8::internal 1523 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/factory.h ('k') | src/full-codegen.cc » ('j') | src/objects.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698