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

Side by Side Diff: src/runtime.cc

Issue 13542002: Calling a generator function returns a generator object (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Fix nits; generator object fields are undefined if not set 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/runtime.h ('k') | test/mjsunit/harmony/generators-instantiation.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 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 2274 matching lines...) Expand 10 before | Expand all | Expand 10 after
2285 HandleScope scope(isolate); 2285 HandleScope scope(isolate);
2286 ASSERT(args.length() == 2); 2286 ASSERT(args.length() == 2);
2287 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); 2287 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
2288 CONVERT_SMI_ARG_CHECKED(num, 1); 2288 CONVERT_SMI_ARG_CHECKED(num, 1);
2289 RUNTIME_ASSERT(num >= 0); 2289 RUNTIME_ASSERT(num >= 0);
2290 SetExpectedNofProperties(function, num); 2290 SetExpectedNofProperties(function, num);
2291 return isolate->heap()->undefined_value(); 2291 return isolate->heap()->undefined_value();
2292 } 2292 }
2293 2293
2294 2294
2295 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateJSGeneratorObject) {
2296 NoHandleAllocation ha(isolate);
2297 ASSERT(args.length() == 0);
2298 JavaScriptFrameIterator it(isolate);
2299 JavaScriptFrame* frame = it.frame();
2300 JSFunction* function = JSFunction::cast(frame->function());
2301 RUNTIME_ASSERT(function->shared()->is_generator());
2302
2303 JSGeneratorObject* generator;
2304 if (frame->IsConstructor()) {
2305 generator = JSGeneratorObject::cast(frame->receiver());
2306 } else {
2307 MaybeObject* maybe_generator =
2308 isolate->heap()->AllocateJSGeneratorObject(function);
2309 if (!maybe_generator->To(&generator)) return maybe_generator;
2310 }
2311 generator->set_function(function);
2312 generator->set_context(isolate->heap()->undefined_value());
2313 generator->set_continuation(0);
2314 generator->set_operand_stack(isolate->heap()->empty_fixed_array());
2315
2316 return generator;
2317 }
2318
2319
2295 MUST_USE_RESULT static MaybeObject* CharFromCode(Isolate* isolate, 2320 MUST_USE_RESULT static MaybeObject* CharFromCode(Isolate* isolate,
2296 Object* char_code) { 2321 Object* char_code) {
2297 uint32_t code; 2322 uint32_t code;
2298 if (char_code->ToArrayIndex(&code)) { 2323 if (char_code->ToArrayIndex(&code)) {
2299 if (code <= 0xffff) { 2324 if (code <= 0xffff) {
2300 return isolate->heap()->LookupSingleCharacterStringFromCode(code); 2325 return isolate->heap()->LookupSingleCharacterStringFromCode(code);
2301 } 2326 }
2302 } 2327 }
2303 return isolate->heap()->empty_string(); 2328 return isolate->heap()->empty_string();
2304 } 2329 }
(...skipping 10779 matching lines...) Expand 10 before | Expand all | Expand 10 after
13084 // Handle last resort GC and make sure to allow future allocations 13109 // Handle last resort GC and make sure to allow future allocations
13085 // to grow the heap without causing GCs (if possible). 13110 // to grow the heap without causing GCs (if possible).
13086 isolate->counters()->gc_last_resort_from_js()->Increment(); 13111 isolate->counters()->gc_last_resort_from_js()->Increment();
13087 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 13112 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
13088 "Runtime::PerformGC"); 13113 "Runtime::PerformGC");
13089 } 13114 }
13090 } 13115 }
13091 13116
13092 13117
13093 } } // namespace v8::internal 13118 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime.h ('k') | test/mjsunit/harmony/generators-instantiation.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698