OLD | NEW |
---|---|
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 3272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3283 MaybeObject* maybe_map_obj = AllocateMap(JS_PROXY_TYPE, JSProxy::kSize); | 3283 MaybeObject* maybe_map_obj = AllocateMap(JS_PROXY_TYPE, JSProxy::kSize); |
3284 if (!maybe_map_obj->To<Map>(&map)) return maybe_map_obj; | 3284 if (!maybe_map_obj->To<Map>(&map)) return maybe_map_obj; |
3285 map->set_prototype(prototype); | 3285 map->set_prototype(prototype); |
3286 | 3286 |
3287 // Allocate the proxy object. | 3287 // Allocate the proxy object. |
3288 JSProxy* result; | 3288 JSProxy* result; |
3289 MaybeObject* maybe_result = Allocate(map, NEW_SPACE); | 3289 MaybeObject* maybe_result = Allocate(map, NEW_SPACE); |
3290 if (!maybe_result->To<JSProxy>(&result)) return maybe_result; | 3290 if (!maybe_result->To<JSProxy>(&result)) return maybe_result; |
3291 result->InitializeBody(map->instance_size(), Smi::FromInt(0)); | 3291 result->InitializeBody(map->instance_size(), Smi::FromInt(0)); |
3292 result->set_handler(handler); | 3292 result->set_handler(handler); |
3293 result->set_hash(undefined_value()); | |
3293 return result; | 3294 return result; |
3294 } | 3295 } |
3295 | 3296 |
3296 | 3297 |
3297 MaybeObject* Heap::AllocateJSFunctionProxy(Object* handler, | 3298 MaybeObject* Heap::AllocateJSFunctionProxy(Object* handler, |
3298 Object* call_trap, | 3299 Object* call_trap, |
3299 Object* construct_trap, | 3300 Object* construct_trap, |
3300 Object* prototype) { | 3301 Object* prototype) { |
3301 // Allocate map. | 3302 // Allocate map. |
3302 // TODO(rossberg): Once we optimize proxies, think about a scheme to share | 3303 // TODO(rossberg): Once we optimize proxies, think about a scheme to share |
3303 // maps. Will probably depend on the identity of the handler object, too. | 3304 // maps. Will probably depend on the identity of the handler object, too. |
3304 Map* map; | 3305 Map* map; |
3305 MaybeObject* maybe_map_obj = | 3306 MaybeObject* maybe_map_obj = |
3306 AllocateMap(JS_FUNCTION_PROXY_TYPE, JSFunctionProxy::kSize); | 3307 AllocateMap(JS_FUNCTION_PROXY_TYPE, JSFunctionProxy::kSize); |
3307 if (!maybe_map_obj->To<Map>(&map)) return maybe_map_obj; | 3308 if (!maybe_map_obj->To<Map>(&map)) return maybe_map_obj; |
3308 map->set_prototype(prototype); | 3309 map->set_prototype(prototype); |
3309 | 3310 |
3310 // Allocate the proxy object. | 3311 // Allocate the proxy object. |
3311 JSFunctionProxy* result; | 3312 JSFunctionProxy* result; |
3312 MaybeObject* maybe_result = Allocate(map, NEW_SPACE); | 3313 MaybeObject* maybe_result = Allocate(map, NEW_SPACE); |
3313 if (!maybe_result->To<JSFunctionProxy>(&result)) return maybe_result; | 3314 if (!maybe_result->To<JSFunctionProxy>(&result)) return maybe_result; |
3314 result->InitializeBody(map->instance_size(), Smi::FromInt(0)); | 3315 result->InitializeBody(map->instance_size(), Smi::FromInt(0)); |
3315 result->set_handler(handler); | 3316 result->set_handler(handler); |
3317 result->set_hash(undefined_value()); | |
3316 result->set_call_trap(call_trap); | 3318 result->set_call_trap(call_trap); |
3317 result->set_construct_trap(construct_trap); | 3319 result->set_construct_trap(construct_trap); |
3318 return result; | 3320 return result; |
3319 } | 3321 } |
3320 | 3322 |
3321 | 3323 |
3322 MaybeObject* Heap::AllocateGlobalObject(JSFunction* constructor) { | 3324 MaybeObject* Heap::AllocateGlobalObject(JSFunction* constructor) { |
3323 ASSERT(constructor->has_initial_map()); | 3325 ASSERT(constructor->has_initial_map()); |
3324 Map* map = constructor->initial_map(); | 3326 Map* map = constructor->initial_map(); |
3325 | 3327 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3456 } | 3458 } |
3457 // Return the new clone. | 3459 // Return the new clone. |
3458 return clone; | 3460 return clone; |
3459 } | 3461 } |
3460 | 3462 |
3461 | 3463 |
3462 MaybeObject* Heap::ReinitializeJSReceiver( | 3464 MaybeObject* Heap::ReinitializeJSReceiver( |
3463 JSReceiver* object, InstanceType type, int size) { | 3465 JSReceiver* object, InstanceType type, int size) { |
3464 ASSERT(type >= FIRST_JS_RECEIVER_TYPE); | 3466 ASSERT(type >= FIRST_JS_RECEIVER_TYPE); |
3465 | 3467 |
3468 // Save identity hash. | |
3469 MaybeObject* maybe_hash = object->GetIdentityHash(JSReceiver::OMIT_CREATION); | |
3470 | |
3466 // Allocate fresh map. | 3471 // Allocate fresh map. |
3467 // TODO(rossberg): Once we optimize proxies, cache these maps. | 3472 // TODO(rossberg): Once we optimize proxies, cache these maps. |
3468 Map* map; | 3473 Map* map; |
3469 MaybeObject* maybe_map_obj = AllocateMap(type, size); | 3474 MaybeObject* maybe_map_obj = AllocateMap(type, size); |
3470 if (!maybe_map_obj->To<Map>(&map)) return maybe_map_obj; | 3475 if (!maybe_map_obj->To<Map>(&map)) return maybe_map_obj; |
3471 | 3476 |
3472 // Check that the receiver has at least the size of the fresh object. | 3477 // Check that the receiver has at least the size of the fresh object. |
3473 int size_difference = object->map()->instance_size() - map->instance_size(); | 3478 int size_difference = object->map()->instance_size() - map->instance_size(); |
3474 ASSERT(size_difference >= 0); | 3479 ASSERT(size_difference >= 0); |
3475 | 3480 |
(...skipping 28 matching lines...) Expand all Loading... | |
3504 if (!maybe_func->To<JSFunction>(&func)) return maybe_func; | 3509 if (!maybe_func->To<JSFunction>(&func)) return maybe_func; |
3505 func->set_context(isolate()->context()->global_context()); | 3510 func->set_context(isolate()->context()->global_context()); |
3506 } | 3511 } |
3507 | 3512 |
3508 // Put in filler if the new object is smaller than the old. | 3513 // Put in filler if the new object is smaller than the old. |
3509 if (size_difference > 0) { | 3514 if (size_difference > 0) { |
3510 CreateFillerObjectAt( | 3515 CreateFillerObjectAt( |
3511 object->address() + map->instance_size(), size_difference); | 3516 object->address() + map->instance_size(), size_difference); |
3512 } | 3517 } |
3513 | 3518 |
3519 // Inherit identity, if it was present. | |
3520 Object* hash; | |
3521 if (maybe_hash->To<Object>(&hash) && hash->IsSmi()) { | |
3522 JSObject* jsobj = JSObject::cast(object); | |
3523 JSObject* hidden_props; | |
3524 MaybeObject* maybe = jsobj->GetHiddenProperties(JSObject::ALLOW_CREATION); | |
Michael Starzinger
2011/09/09 09:40:00
Can we move that into a separate method JSObject::
rossberg
2011/09/12 10:50:08
Done.
| |
3525 if (!maybe->To<JSObject>(&hidden_props)) return maybe; | |
3526 maybe = hidden_props->SetLocalPropertyIgnoreAttributes( | |
3527 identity_hash_symbol(), hash, NONE); | |
3528 if (maybe->IsFailure()) return maybe; | |
3529 } | |
3530 | |
3514 return object; | 3531 return object; |
3515 } | 3532 } |
3516 | 3533 |
3517 | 3534 |
3518 MaybeObject* Heap::ReinitializeJSGlobalProxy(JSFunction* constructor, | 3535 MaybeObject* Heap::ReinitializeJSGlobalProxy(JSFunction* constructor, |
3519 JSGlobalProxy* object) { | 3536 JSGlobalProxy* object) { |
3520 ASSERT(constructor->has_initial_map()); | 3537 ASSERT(constructor->has_initial_map()); |
3521 Map* map = constructor->initial_map(); | 3538 Map* map = constructor->initial_map(); |
3522 | 3539 |
3523 // Check that the already allocated object has the same size and type as | 3540 // Check that the already allocated object has the same size and type as |
(...skipping 2589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6113 } | 6130 } |
6114 | 6131 |
6115 | 6132 |
6116 void ExternalStringTable::TearDown() { | 6133 void ExternalStringTable::TearDown() { |
6117 new_space_strings_.Free(); | 6134 new_space_strings_.Free(); |
6118 old_space_strings_.Free(); | 6135 old_space_strings_.Free(); |
6119 } | 6136 } |
6120 | 6137 |
6121 | 6138 |
6122 } } // namespace v8::internal | 6139 } } // namespace v8::internal |
OLD | NEW |