Chromium Code Reviews

Side by Side Diff: src/heap.cc

Issue 6932068: A first skeleton for introducing Harmony proxies (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | 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 3193 matching lines...)
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 Object* map_obj;
3217 MaybeObject* maybe_map_obj = AllocateMap(JS_PROXY_TYPE, JSProxy::kSize);
3218 if (!maybe_map_obj->ToObject(&map_obj)) return maybe_map_obj;
3219 Map* map = Map::cast(map_obj);
3220 map->set_prototype(prototype);
3221 map->set_pre_allocated_property_fields(1);
3222 map->set_inobject_properties(1);
3223
3224 // Allocate the proxy object.
3225 Object* result;
3226 MaybeObject* maybe_result = Allocate(map, NEW_SPACE);
3227 if (!maybe_result->ToObject(&result)) return maybe_result;
3228 JSProxy::cast(result)->set_handler(handler);
3229 return result;
3230 }
3231
3232
3214 MaybeObject* Heap::AllocateGlobalObject(JSFunction* constructor) { 3233 MaybeObject* Heap::AllocateGlobalObject(JSFunction* constructor) {
3215 ASSERT(constructor->has_initial_map()); 3234 ASSERT(constructor->has_initial_map());
3216 Map* map = constructor->initial_map(); 3235 Map* map = constructor->initial_map();
3217 3236
3218 // Make sure no field properties are described in the initial map. 3237 // Make sure no field properties are described in the initial map.
3219 // This guarantees us that normalizing the properties does not 3238 // This guarantees us that normalizing the properties does not
3220 // require us to change property values to JSGlobalPropertyCells. 3239 // require us to change property values to JSGlobalPropertyCells.
3221 ASSERT(map->NextFreePropertyIndex() == 0); 3240 ASSERT(map->NextFreePropertyIndex() == 0);
3222 3241
3223 // Make sure we don't have a ton of pre-allocated slots in the 3242 // Make sure we don't have a ton of pre-allocated slots in the
(...skipping 2635 matching lines...)
5859 } 5878 }
5860 5879
5861 5880
5862 void ExternalStringTable::TearDown() { 5881 void ExternalStringTable::TearDown() {
5863 new_space_strings_.Free(); 5882 new_space_strings_.Free();
5864 old_space_strings_.Free(); 5883 old_space_strings_.Free();
5865 } 5884 }
5866 5885
5867 5886
5868 } } // namespace v8::internal 5887 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine