Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 ASSERT(function->shared()->is_generator()); | |
| 2302 | |
| 2303 JSGeneratorObject* generator; | |
| 2304 if (frame->IsConstructor()) { | |
| 2305 generator = JSGeneratorObject::cast(frame->receiver()); | |
|
Michael Starzinger
2013/04/12 16:53:31
We shouldn't use the implicit receiver as the resu
Michael Starzinger
2013/04/14 21:32:50
You are right, I totally missed the fact that the
| |
| 2306 } else { | |
| 2307 Map *map; | |
| 2308 if (function->has_initial_map()) { | |
|
Michael Starzinger
2013/04/12 16:53:31
I think we can get by without tweaking the initial
| |
| 2309 map = function->initial_map(); | |
| 2310 } else { | |
| 2311 // Allocate the initial map if absent. | |
| 2312 MaybeObject* maybe_map = isolate->heap()->AllocateInitialMap(function); | |
| 2313 if (!maybe_map->To(&map)) return maybe_map; | |
| 2314 function->set_initial_map(map); | |
| 2315 } | |
| 2316 ASSERT(map->instance_type() == JS_GENERATOR_OBJECT_TYPE); | |
| 2317 // Allocate the generator. | |
| 2318 MaybeObject* maybe_generator = isolate->heap()->Allocate(map, NEW_SPACE); | |
|
Michael Starzinger
2013/04/14 21:32:50
Please move the JSGenerator allocation back into h
wingo
2013/04/15 09:24:57
Done.
| |
| 2319 if (!maybe_generator->To(&generator)) return maybe_generator; | |
| 2320 generator->initialize_properties(); | |
| 2321 generator->initialize_elements(); | |
| 2322 } | |
| 2323 generator->set_function(function); | |
| 2324 generator->set_context(Smi::FromInt(0)); | |
| 2325 generator->set_continuation(0); | |
| 2326 generator->set_operand_stack(Smi::FromInt(0)); | |
| 2327 return generator; | |
| 2328 } | |
| 2329 | |
| 2330 | |
| 2295 MUST_USE_RESULT static MaybeObject* CharFromCode(Isolate* isolate, | 2331 MUST_USE_RESULT static MaybeObject* CharFromCode(Isolate* isolate, |
| 2296 Object* char_code) { | 2332 Object* char_code) { |
| 2297 uint32_t code; | 2333 uint32_t code; |
| 2298 if (char_code->ToArrayIndex(&code)) { | 2334 if (char_code->ToArrayIndex(&code)) { |
| 2299 if (code <= 0xffff) { | 2335 if (code <= 0xffff) { |
| 2300 return isolate->heap()->LookupSingleCharacterStringFromCode(code); | 2336 return isolate->heap()->LookupSingleCharacterStringFromCode(code); |
| 2301 } | 2337 } |
| 2302 } | 2338 } |
| 2303 return isolate->heap()->empty_string(); | 2339 return isolate->heap()->empty_string(); |
| 2304 } | 2340 } |
| (...skipping 10779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 13084 // Handle last resort GC and make sure to allow future allocations | 13120 // Handle last resort GC and make sure to allow future allocations |
| 13085 // to grow the heap without causing GCs (if possible). | 13121 // to grow the heap without causing GCs (if possible). |
| 13086 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13122 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 13087 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13123 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
| 13088 "Runtime::PerformGC"); | 13124 "Runtime::PerformGC"); |
| 13089 } | 13125 } |
| 13090 } | 13126 } |
| 13091 | 13127 |
| 13092 | 13128 |
| 13093 } } // namespace v8::internal | 13129 } } // namespace v8::internal |
| OLD | NEW |