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

Side by Side Diff: src/handles.cc

Issue 115267: Fix for issue 339:... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 7 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/handles.h ('k') | src/objects.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 266
267 267
268 Handle<Object> GetPrototype(Handle<Object> obj) { 268 Handle<Object> GetPrototype(Handle<Object> obj) {
269 Handle<Object> result(obj->GetPrototype()); 269 Handle<Object> result(obj->GetPrototype());
270 return result; 270 return result;
271 } 271 }
272 272
273 273
274 Handle<Object> GetHiddenProperties(Handle<JSObject> obj, 274 Handle<Object> GetHiddenProperties(Handle<JSObject> obj,
275 bool create_if_needed) { 275 bool create_if_needed) {
276 CALL_HEAP_FUNCTION(obj->GetHiddenProperties(create_if_needed), Object); 276 Handle<String> key = Factory::hidden_symbol();
277
278 if (obj->HasFastProperties()) {
279 // If the object has fast properties, check whether the first slot
280 // in the descriptor array matches the hidden symbol. Since the
281 // hidden symbols hash code is zero (and no other string has hash
282 // code zero) it will always occupy the first entry if present.
283 DescriptorArray* descriptors = obj->map()->instance_descriptors();
284 DescriptorReader r(descriptors);
285 if (!r.eos() && (r.GetKey() == *key) && r.IsProperty()) {
286 ASSERT(r.type() == FIELD);
287 return Handle<Object>(obj->FastPropertyAt(r.GetFieldIndex()));
288 }
289 }
290
291 // Only attempt to find the hidden properties in the local object and not
292 // in the prototype chain. Note that HasLocalProperty() can cause a GC in
293 // the general case in the presence of interceptors.
294 if (!obj->HasLocalProperty(*key)) {
295 // Hidden properties object not found. Allocate a new hidden properties
296 // object if requested. Otherwise return the undefined value.
297 if (create_if_needed) {
298 Handle<Object> hidden_obj = Factory::NewJSObject(Top::object_function());
299 return SetProperty(obj, key, hidden_obj, DONT_ENUM);
300 } else {
301 return Factory::undefined_value();
302 }
303 }
304 return GetProperty(obj, key);
277 } 305 }
278 306
279 307
280 Handle<Object> DeleteElement(Handle<JSObject> obj, 308 Handle<Object> DeleteElement(Handle<JSObject> obj,
281 uint32_t index) { 309 uint32_t index) {
282 CALL_HEAP_FUNCTION(obj->DeleteElement(index), Object); 310 CALL_HEAP_FUNCTION(obj->DeleteElement(index), Object);
283 } 311 }
284 312
285 313
286 Handle<Object> DeleteProperty(Handle<JSObject> obj, 314 Handle<Object> DeleteProperty(Handle<JSObject> obj,
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 Handle<Map> new_map = Factory::CopyMapDropTransitions(old_map); 731 Handle<Map> new_map = Factory::CopyMapDropTransitions(old_map);
704 obj->set_map(*new_map); 732 obj->set_map(*new_map);
705 new_map->set_needs_loading(true); 733 new_map->set_needs_loading(true);
706 // Store the lazy loading info in the constructor field. We'll 734 // Store the lazy loading info in the constructor field. We'll
707 // reestablish the constructor from the fixed array after loading. 735 // reestablish the constructor from the fixed array after loading.
708 new_map->set_constructor(*arr); 736 new_map->set_constructor(*arr);
709 ASSERT(!obj->IsLoaded()); 737 ASSERT(!obj->IsLoaded());
710 } 738 }
711 739
712 } } // namespace v8::internal 740 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/handles.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698