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

Side by Side Diff: src/heap.cc

Issue 7391001: Implement sealing, freezing, and related functions for proxies. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Oops, forgot to rebase branch. Created 9 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 3261 matching lines...) Expand 10 before | Expand all | Expand 10 after
3272 3272
3273 // Allocate the proxy object. 3273 // Allocate the proxy object.
3274 Object* result; 3274 Object* result;
3275 MaybeObject* maybe_result = Allocate(map, NEW_SPACE); 3275 MaybeObject* maybe_result = Allocate(map, NEW_SPACE);
3276 if (!maybe_result->ToObject(&result)) return maybe_result; 3276 if (!maybe_result->ToObject(&result)) return maybe_result;
3277 JSProxy::cast(result)->set_handler(handler); 3277 JSProxy::cast(result)->set_handler(handler);
3278 return result; 3278 return result;
3279 } 3279 }
3280 3280
3281 3281
3282 MaybeObject* Heap::AllocateGlobalObject(JSFunction* constructor) { 3282 MaybeObject* Heap::AllocateGlobalObject(JSFunction* constructor) {
Mads Ager (chromium) 2011/07/17 10:43:47 Accidental edit. :-)
rossberg 2011/07/18 10:53:53 Done.
3283 ASSERT(constructor->has_initial_map()); 3283 ASSERT(constructor->has_initial_map());
3284 Map* map = constructor->initial_map(); 3284 Map* map = constructor->initial_map();
3285 3285
3286 // Make sure no field properties are described in the initial map. 3286 // Make sure no field properties are described in the initial map.
3287 // This guarantees us that normalizing the properties does not 3287 // This guarantees us that normalizing the properties does not
3288 // require us to change property values to JSGlobalPropertyCells. 3288 // require us to change property values to JSGlobalPropertyCells.
3289 ASSERT(map->NextFreePropertyIndex() == 0); 3289 ASSERT(map->NextFreePropertyIndex() == 0);
3290 3290
3291 // Make sure we don't have a ton of pre-allocated slots in the 3291 // Make sure we don't have a ton of pre-allocated slots in the
3292 // global objects. They will be unused once we normalize the object. 3292 // global objects. They will be unused once we normalize the object.
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
3407 { MaybeObject* maybe_prop = CopyFixedArray(properties); 3407 { MaybeObject* maybe_prop = CopyFixedArray(properties);
3408 if (!maybe_prop->ToObject(&prop)) return maybe_prop; 3408 if (!maybe_prop->ToObject(&prop)) return maybe_prop;
3409 } 3409 }
3410 JSObject::cast(clone)->set_properties(FixedArray::cast(prop)); 3410 JSObject::cast(clone)->set_properties(FixedArray::cast(prop));
3411 } 3411 }
3412 // Return the new clone. 3412 // Return the new clone.
3413 return clone; 3413 return clone;
3414 } 3414 }
3415 3415
3416 3416
3417 MaybeObject* Heap::ReinitializeJSReceiverAsJSObject(JSReceiver* object) {
3418 // Allocate fresh map.
3419 // TODO(rossberg): Once we optimize proxies, cache these maps.
3420 Map* map;
3421 MaybeObject* maybe_map_obj =
3422 AllocateMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
3423 if (!maybe_map_obj->To<Map>(&map)) return maybe_map_obj;
3424
3425 // Check that the receiver has the same size as a fresh object.
3426 ASSERT(map->instance_size() == object->map()->instance_size());
3427
3428 map->set_prototype(object->map()->prototype());
3429
3430 // Allocate the backing storage for the properties.
3431 int prop_size = map->unused_property_fields() - map->inobject_properties();
3432 Object* properties;
3433 { MaybeObject* maybe_properties = AllocateFixedArray(prop_size, TENURED);
3434 if (!maybe_properties->ToObject(&properties)) return maybe_properties;
3435 }
3436
3437 // Reset the map for the object.
3438 object->set_map(map);
3439
3440 // Reinitialize the object from the constructor map.
3441 InitializeJSObjectFromMap(JSObject::cast(object),
3442 FixedArray::cast(properties), map);
3443 return object;
3444 }
3445
3446
3417 MaybeObject* Heap::ReinitializeJSGlobalProxy(JSFunction* constructor, 3447 MaybeObject* Heap::ReinitializeJSGlobalProxy(JSFunction* constructor,
3418 JSGlobalProxy* object) { 3448 JSGlobalProxy* object) {
3419 ASSERT(constructor->has_initial_map()); 3449 ASSERT(constructor->has_initial_map());
3420 Map* map = constructor->initial_map(); 3450 Map* map = constructor->initial_map();
3421 3451
3422 // Check that the already allocated object has the same size and type as 3452 // Check that the already allocated object has the same size and type as
3423 // objects allocated using the constructor. 3453 // objects allocated using the constructor.
3424 ASSERT(map->instance_size() == object->map()->instance_size()); 3454 ASSERT(map->instance_size() == object->map()->instance_size());
3425 ASSERT(map->instance_type() == object->map()->instance_type()); 3455 ASSERT(map->instance_type() == object->map()->instance_type());
3426 3456
(...skipping 2568 matching lines...) Expand 10 before | Expand all | Expand 10 after
5995 } 6025 }
5996 6026
5997 6027
5998 void ExternalStringTable::TearDown() { 6028 void ExternalStringTable::TearDown() {
5999 new_space_strings_.Free(); 6029 new_space_strings_.Free();
6000 old_space_strings_.Free(); 6030 old_space_strings_.Free();
6001 } 6031 }
6002 6032
6003 6033
6004 } } // namespace v8::internal 6034 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698