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

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: Addressing Mads' comments, plus bug fix. 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
« no previous file with comments | « src/heap.h ('k') | src/messages.js » ('j') | src/objects.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3249 matching lines...) Expand 10 before | Expand all | Expand 10 after
3260 3260
3261 3261
3262 MaybeObject* Heap::AllocateJSProxy(Object* handler, Object* prototype) { 3262 MaybeObject* Heap::AllocateJSProxy(Object* handler, Object* prototype) {
3263 // Allocate map. 3263 // Allocate map.
3264 // TODO(rossberg): Once we optimize proxies, think about a scheme to share 3264 // TODO(rossberg): Once we optimize proxies, think about a scheme to share
3265 // maps. Will probably depend on the identity of the handler object, too. 3265 // maps. Will probably depend on the identity of the handler object, too.
3266 Map* map; 3266 Map* map;
3267 MaybeObject* maybe_map_obj = AllocateMap(JS_PROXY_TYPE, JSProxy::kSize); 3267 MaybeObject* maybe_map_obj = AllocateMap(JS_PROXY_TYPE, JSProxy::kSize);
3268 if (!maybe_map_obj->To<Map>(&map)) return maybe_map_obj; 3268 if (!maybe_map_obj->To<Map>(&map)) return maybe_map_obj;
3269 map->set_prototype(prototype); 3269 map->set_prototype(prototype);
3270 map->set_pre_allocated_property_fields(1);
3271 map->set_inobject_properties(1);
3272 3270
3273 // Allocate the proxy object. 3271 // Allocate the proxy object.
3274 Object* result; 3272 Object* result;
3275 MaybeObject* maybe_result = Allocate(map, NEW_SPACE); 3273 MaybeObject* maybe_result = Allocate(map, NEW_SPACE);
3276 if (!maybe_result->ToObject(&result)) return maybe_result; 3274 if (!maybe_result->ToObject(&result)) return maybe_result;
3277 JSProxy::cast(result)->set_handler(handler); 3275 JSProxy::cast(result)->set_handler(handler);
3276 JSProxy::cast(result)->set_padding(Smi::FromInt(0));
3278 return result; 3277 return result;
3279 } 3278 }
3280 3279
3281 3280
3282 MaybeObject* Heap::AllocateGlobalObject(JSFunction* constructor) { 3281 MaybeObject* Heap::AllocateGlobalObject(JSFunction* constructor) {
3283 ASSERT(constructor->has_initial_map()); 3282 ASSERT(constructor->has_initial_map());
3284 Map* map = constructor->initial_map(); 3283 Map* map = constructor->initial_map();
3285 3284
3286 // Make sure no field properties are described in the initial map. 3285 // Make sure no field properties are described in the initial map.
3287 // This guarantees us that normalizing the properties does not 3286 // This guarantees us that normalizing the properties does not
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
3407 { MaybeObject* maybe_prop = CopyFixedArray(properties); 3406 { MaybeObject* maybe_prop = CopyFixedArray(properties);
3408 if (!maybe_prop->ToObject(&prop)) return maybe_prop; 3407 if (!maybe_prop->ToObject(&prop)) return maybe_prop;
3409 } 3408 }
3410 JSObject::cast(clone)->set_properties(FixedArray::cast(prop)); 3409 JSObject::cast(clone)->set_properties(FixedArray::cast(prop));
3411 } 3410 }
3412 // Return the new clone. 3411 // Return the new clone.
3413 return clone; 3412 return clone;
3414 } 3413 }
3415 3414
3416 3415
3416 MaybeObject* Heap::ReinitializeJSProxyAsJSObject(JSProxy* object) {
3417 // Allocate fresh map.
3418 // TODO(rossberg): Once we optimize proxies, cache these maps.
3419 Map* map;
3420 MaybeObject* maybe_map_obj =
3421 AllocateMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
3422 if (!maybe_map_obj->To<Map>(&map)) return maybe_map_obj;
3423
3424 // Check that the receiver has the same size as a fresh object.
3425 ASSERT(map->instance_size() == object->map()->instance_size());
3426
3427 map->set_prototype(object->map()->prototype());
3428
3429 // Allocate the backing storage for the properties.
3430 int prop_size = map->unused_property_fields() - map->inobject_properties();
3431 Object* properties;
3432 { MaybeObject* maybe_properties = AllocateFixedArray(prop_size, TENURED);
3433 if (!maybe_properties->ToObject(&properties)) return maybe_properties;
3434 }
3435
3436 // Reset the map for the object.
3437 object->set_map(map);
3438
3439 // Reinitialize the object from the constructor map.
3440 InitializeJSObjectFromMap(JSObject::cast(object),
3441 FixedArray::cast(properties), map);
3442 return object;
3443 }
3444
3445
3417 MaybeObject* Heap::ReinitializeJSGlobalProxy(JSFunction* constructor, 3446 MaybeObject* Heap::ReinitializeJSGlobalProxy(JSFunction* constructor,
3418 JSGlobalProxy* object) { 3447 JSGlobalProxy* object) {
3419 ASSERT(constructor->has_initial_map()); 3448 ASSERT(constructor->has_initial_map());
3420 Map* map = constructor->initial_map(); 3449 Map* map = constructor->initial_map();
3421 3450
3422 // Check that the already allocated object has the same size and type as 3451 // Check that the already allocated object has the same size and type as
3423 // objects allocated using the constructor. 3452 // objects allocated using the constructor.
3424 ASSERT(map->instance_size() == object->map()->instance_size()); 3453 ASSERT(map->instance_size() == object->map()->instance_size());
3425 ASSERT(map->instance_type() == object->map()->instance_type()); 3454 ASSERT(map->instance_type() == object->map()->instance_type());
3426 3455
(...skipping 2568 matching lines...) Expand 10 before | Expand all | Expand 10 after
5995 } 6024 }
5996 6025
5997 6026
5998 void ExternalStringTable::TearDown() { 6027 void ExternalStringTable::TearDown() {
5999 new_space_strings_.Free(); 6028 new_space_strings_.Free();
6000 old_space_strings_.Free(); 6029 old_space_strings_.Free();
6001 } 6030 }
6002 6031
6003 6032
6004 } } // namespace v8::internal 6033 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap.h ('k') | src/messages.js » ('j') | src/objects.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698