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 3193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3204 AllocateJSObjectFromMap(constructor->initial_map(), pretenure); | 3204 AllocateJSObjectFromMap(constructor->initial_map(), pretenure); |
3205 #ifdef DEBUG | 3205 #ifdef DEBUG |
3206 // Make sure result is NOT a global object if valid. | 3206 // Make sure result is NOT a global object if valid. |
3207 Object* non_failure; | 3207 Object* non_failure; |
3208 ASSERT(!result->ToObject(&non_failure) || !non_failure->IsGlobalObject()); | 3208 ASSERT(!result->ToObject(&non_failure) || !non_failure->IsGlobalObject()); |
3209 #endif | 3209 #endif |
3210 return result; | 3210 return result; |
3211 } | 3211 } |
3212 | 3212 |
3213 | 3213 |
3214 MaybeObject* Heap::AllocateJSProxy(Object* handler, Object* prototype) { | |
3215 // Allocate map. | |
3216 // TODO(rossberg): Once we optimize proxies, think about a scheme to share | |
3217 // maps. Will probably depend on the identity of the handler object, too. | |
3218 Object* map_obj; | |
3219 MaybeObject* maybe_map_obj = AllocateMap(JS_PROXY_TYPE, JSProxy::kSize); | |
3220 if (!maybe_map_obj->ToObject(&map_obj)) return maybe_map_obj; | |
Vyacheslav Egorov (Chromium)
2011/05/22 14:45:50
I introduced a helpful templated To<T> accessor to
rossberg
2011/05/23 08:45:28
Ah, nice. Done.
| |
3221 Map* map = Map::cast(map_obj); | |
3222 map->set_prototype(prototype); | |
3223 map->set_pre_allocated_property_fields(1); | |
3224 map->set_inobject_properties(1); | |
3225 | |
3226 // Allocate the proxy object. | |
3227 Object* result; | |
3228 MaybeObject* maybe_result = Allocate(map, NEW_SPACE); | |
3229 if (!maybe_result->ToObject(&result)) return maybe_result; | |
3230 JSProxy::cast(result)->set_handler(handler); | |
3231 return result; | |
3232 } | |
3233 | |
3234 | |
3214 MaybeObject* Heap::AllocateGlobalObject(JSFunction* constructor) { | 3235 MaybeObject* Heap::AllocateGlobalObject(JSFunction* constructor) { |
3215 ASSERT(constructor->has_initial_map()); | 3236 ASSERT(constructor->has_initial_map()); |
3216 Map* map = constructor->initial_map(); | 3237 Map* map = constructor->initial_map(); |
3217 | 3238 |
3218 // Make sure no field properties are described in the initial map. | 3239 // Make sure no field properties are described in the initial map. |
3219 // This guarantees us that normalizing the properties does not | 3240 // This guarantees us that normalizing the properties does not |
3220 // require us to change property values to JSGlobalPropertyCells. | 3241 // require us to change property values to JSGlobalPropertyCells. |
3221 ASSERT(map->NextFreePropertyIndex() == 0); | 3242 ASSERT(map->NextFreePropertyIndex() == 0); |
3222 | 3243 |
3223 // Make sure we don't have a ton of pre-allocated slots in the | 3244 // Make sure we don't have a ton of pre-allocated slots in the |
(...skipping 2635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5859 } | 5880 } |
5860 | 5881 |
5861 | 5882 |
5862 void ExternalStringTable::TearDown() { | 5883 void ExternalStringTable::TearDown() { |
5863 new_space_strings_.Free(); | 5884 new_space_strings_.Free(); |
5864 old_space_strings_.Free(); | 5885 old_space_strings_.Free(); |
5865 } | 5886 } |
5866 | 5887 |
5867 | 5888 |
5868 } } // namespace v8::internal | 5889 } } // namespace v8::internal |
OLD | NEW |