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

Side by Side Diff: src/heap.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/heap.h ('k') | src/objects.h » ('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 4071 matching lines...) Expand 10 before | Expand all | Expand 10 after
4082 4082
4083 MaybeObject* Heap::AllocateInitialMap(JSFunction* fun) { 4083 MaybeObject* Heap::AllocateInitialMap(JSFunction* fun) {
4084 ASSERT(!fun->has_initial_map()); 4084 ASSERT(!fun->has_initial_map());
4085 4085
4086 // First create a new map with the size and number of in-object properties 4086 // First create a new map with the size and number of in-object properties
4087 // suggested by the function. 4087 // suggested by the function.
4088 InstanceType instance_type; 4088 InstanceType instance_type;
4089 int instance_size; 4089 int instance_size;
4090 int in_object_properties; 4090 int in_object_properties;
4091 if (fun->shared()->is_generator()) { 4091 if (fun->shared()->is_generator()) {
4092 // TODO(wingo): Replace with JS_GENERATOR_OBJECT_TYPE. 4092 instance_type = JS_GENERATOR_OBJECT_TYPE;
4093 instance_type = JS_OBJECT_TYPE; 4093 instance_size = JSGeneratorObject::kSize;
4094 instance_size = JSObject::kHeaderSize;
4095 in_object_properties = 0; 4094 in_object_properties = 0;
4096 } else { 4095 } else {
4097 instance_type = JS_OBJECT_TYPE; 4096 instance_type = JS_OBJECT_TYPE;
4098 instance_size = fun->shared()->CalculateInstanceSize(); 4097 instance_size = fun->shared()->CalculateInstanceSize();
4099 in_object_properties = fun->shared()->CalculateInObjectProperties(); 4098 in_object_properties = fun->shared()->CalculateInObjectProperties();
4100 } 4099 }
4101 Map* map; 4100 Map* map;
4102 MaybeObject* maybe_map = AllocateMap(instance_type, instance_size); 4101 MaybeObject* maybe_map = AllocateMap(instance_type, instance_size);
4103 if (!maybe_map->To(&map)) return maybe_map; 4102 if (!maybe_map->To(&map)) return maybe_map;
4104 4103
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
4333 } 4332 }
4334 #ifdef DEBUG 4333 #ifdef DEBUG
4335 // Make sure result is NOT a global object if valid. 4334 // Make sure result is NOT a global object if valid.
4336 Object* non_failure; 4335 Object* non_failure;
4337 ASSERT(!result->ToObject(&non_failure) || !non_failure->IsGlobalObject()); 4336 ASSERT(!result->ToObject(&non_failure) || !non_failure->IsGlobalObject());
4338 #endif 4337 #endif
4339 return result; 4338 return result;
4340 } 4339 }
4341 4340
4342 4341
4342 MaybeObject* Heap::AllocateJSGeneratorObject(JSFunction *function) {
4343 ASSERT(function->shared()->is_generator());
4344 Map *map;
4345 if (function->has_initial_map()) {
4346 map = function->initial_map();
4347 } else {
4348 // Allocate the initial map if absent.
4349 MaybeObject* maybe_map = AllocateInitialMap(function);
4350 if (!maybe_map->To(&map)) return maybe_map;
4351 function->set_initial_map(map);
4352 }
4353 ASSERT(map->instance_type() == JS_GENERATOR_OBJECT_TYPE);
4354 return AllocateJSObjectFromMap(map);
4355 }
4356
4357
4343 MaybeObject* Heap::AllocateJSModule(Context* context, ScopeInfo* scope_info) { 4358 MaybeObject* Heap::AllocateJSModule(Context* context, ScopeInfo* scope_info) {
4344 // Allocate a fresh map. Modules do not have a prototype. 4359 // Allocate a fresh map. Modules do not have a prototype.
4345 Map* map; 4360 Map* map;
4346 MaybeObject* maybe_map = AllocateMap(JS_MODULE_TYPE, JSModule::kSize); 4361 MaybeObject* maybe_map = AllocateMap(JS_MODULE_TYPE, JSModule::kSize);
4347 if (!maybe_map->To(&map)) return maybe_map; 4362 if (!maybe_map->To(&map)) return maybe_map;
4348 // Allocate the object based on the map. 4363 // Allocate the object based on the map.
4349 JSModule* module; 4364 JSModule* module;
4350 MaybeObject* maybe_module = AllocateJSObjectFromMap(map, TENURED); 4365 MaybeObject* maybe_module = AllocateJSObjectFromMap(map, TENURED);
4351 if (!maybe_module->To(&module)) return maybe_module; 4366 if (!maybe_module->To(&module)) return maybe_module;
4352 module->set_context(context); 4367 module->set_context(context);
(...skipping 3480 matching lines...) Expand 10 before | Expand all | Expand 10 after
7833 static_cast<int>(object_sizes_last_time_[index])); 7848 static_cast<int>(object_sizes_last_time_[index]));
7834 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) 7849 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT)
7835 #undef ADJUST_LAST_TIME_OBJECT_COUNT 7850 #undef ADJUST_LAST_TIME_OBJECT_COUNT
7836 7851
7837 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); 7852 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_));
7838 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); 7853 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_));
7839 ClearObjectStats(); 7854 ClearObjectStats();
7840 } 7855 }
7841 7856
7842 } } // namespace v8::internal 7857 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698