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

Side by Side Diff: src/handles.cc

Issue 7349005: Added dictionary that can use objects as keys. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Added unit test to gyp buildfile as well. 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/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 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 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 CALL_HEAP_FUNCTION(object->GetIsolate(), object->PreventExtensions(), Object); 420 CALL_HEAP_FUNCTION(object->GetIsolate(), object->PreventExtensions(), Object);
421 } 421 }
422 422
423 423
424 Handle<Object> GetHiddenProperties(Handle<JSObject> obj, 424 Handle<Object> GetHiddenProperties(Handle<JSObject> obj,
425 bool create_if_needed) { 425 bool create_if_needed) {
426 Isolate* isolate = obj->GetIsolate(); 426 Isolate* isolate = obj->GetIsolate();
427 Object* holder = obj->BypassGlobalProxy(); 427 Object* holder = obj->BypassGlobalProxy();
428 if (holder->IsUndefined()) return isolate->factory()->undefined_value(); 428 if (holder->IsUndefined()) return isolate->factory()->undefined_value();
429 obj = Handle<JSObject>(JSObject::cast(holder), isolate); 429 obj = Handle<JSObject>(JSObject::cast(holder), isolate);
430 430 CALL_HEAP_FUNCTION(isolate,
431 if (obj->HasFastProperties()) { 431 obj->GetHiddenProperties(create_if_needed),
432 // If the object has fast properties, check whether the first slot 432 Object);
433 // in the descriptor array matches the hidden symbol. Since the
434 // hidden symbols hash code is zero (and no other string has hash
435 // code zero) it will always occupy the first entry if present.
436 DescriptorArray* descriptors = obj->map()->instance_descriptors();
437 if ((descriptors->number_of_descriptors() > 0) &&
438 (descriptors->GetKey(0) == isolate->heap()->hidden_symbol()) &&
439 descriptors->IsProperty(0)) {
440 ASSERT(descriptors->GetType(0) == FIELD);
441 return Handle<Object>(obj->FastPropertyAt(descriptors->GetFieldIndex(0)),
442 isolate);
443 }
444 }
445
446 // Only attempt to find the hidden properties in the local object and not
447 // in the prototype chain. Note that HasLocalProperty() can cause a GC in
448 // the general case in the presence of interceptors.
449 if (!obj->HasHiddenPropertiesObject()) {
450 // Hidden properties object not found. Allocate a new hidden properties
451 // object if requested. Otherwise return the undefined value.
452 if (create_if_needed) {
453 Handle<Object> hidden_obj =
454 isolate->factory()->NewJSObject(isolate->object_function());
455 CALL_HEAP_FUNCTION(isolate,
456 obj->SetHiddenPropertiesObject(*hidden_obj), Object);
457 } else {
458 return isolate->factory()->undefined_value();
459 }
460 }
461 return Handle<Object>(obj->GetHiddenPropertiesObject(), isolate);
462 } 433 }
463 434
464 435
436 Handle<Smi> GetIdentityHash(Handle<JSObject> obj) {
437 CALL_HEAP_FUNCTION(obj->GetIsolate(), obj->GetIdentityHash(), Smi);
438 }
439
440
465 Handle<Object> DeleteElement(Handle<JSObject> obj, 441 Handle<Object> DeleteElement(Handle<JSObject> obj,
466 uint32_t index) { 442 uint32_t index) {
467 CALL_HEAP_FUNCTION(obj->GetIsolate(), 443 CALL_HEAP_FUNCTION(obj->GetIsolate(),
468 obj->DeleteElement(index, JSObject::NORMAL_DELETION), 444 obj->DeleteElement(index, JSObject::NORMAL_DELETION),
469 Object); 445 Object);
470 } 446 }
471 447
472 448
473 Handle<Object> DeleteProperty(Handle<JSObject> obj, 449 Handle<Object> DeleteProperty(Handle<JSObject> obj,
474 Handle<String> prop) { 450 Handle<String> prop) {
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 947
972 bool CompileOptimized(Handle<JSFunction> function, 948 bool CompileOptimized(Handle<JSFunction> function,
973 int osr_ast_id, 949 int osr_ast_id,
974 ClearExceptionFlag flag) { 950 ClearExceptionFlag flag) {
975 CompilationInfo info(function); 951 CompilationInfo info(function);
976 info.SetOptimizing(osr_ast_id); 952 info.SetOptimizing(osr_ast_id);
977 return CompileLazyHelper(&info, flag); 953 return CompileLazyHelper(&info, flag);
978 } 954 }
979 955
980 } } // namespace v8::internal 956 } } // 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