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 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 CALL_HEAP_FUNCTION(isolate, | 430 |
431 obj->GetHiddenProperties(create_if_needed), | 431 if (obj->HasFastProperties()) { |
432 Object); | 432 // If the object has fast properties, check whether the first slot |
| 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); |
433 } | 462 } |
434 | 463 |
435 | 464 |
436 Handle<Smi> GetIdentityHash(Handle<JSObject> obj) { | |
437 CALL_HEAP_FUNCTION(obj->GetIsolate(), obj->GetIdentityHash(), Smi); | |
438 } | |
439 | |
440 | |
441 Handle<Object> DeleteElement(Handle<JSObject> obj, | 465 Handle<Object> DeleteElement(Handle<JSObject> obj, |
442 uint32_t index) { | 466 uint32_t index) { |
443 CALL_HEAP_FUNCTION(obj->GetIsolate(), | 467 CALL_HEAP_FUNCTION(obj->GetIsolate(), |
444 obj->DeleteElement(index, JSObject::NORMAL_DELETION), | 468 obj->DeleteElement(index, JSObject::NORMAL_DELETION), |
445 Object); | 469 Object); |
446 } | 470 } |
447 | 471 |
448 | 472 |
449 Handle<Object> DeleteProperty(Handle<JSObject> obj, | 473 Handle<Object> DeleteProperty(Handle<JSObject> obj, |
450 Handle<String> prop) { | 474 Handle<String> prop) { |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
942 | 966 |
943 bool CompileOptimized(Handle<JSFunction> function, | 967 bool CompileOptimized(Handle<JSFunction> function, |
944 int osr_ast_id, | 968 int osr_ast_id, |
945 ClearExceptionFlag flag) { | 969 ClearExceptionFlag flag) { |
946 CompilationInfo info(function); | 970 CompilationInfo info(function); |
947 info.SetOptimizing(osr_ast_id); | 971 info.SetOptimizing(osr_ast_id); |
948 return CompileLazyHelper(&info, flag); | 972 return CompileLazyHelper(&info, flag); |
949 } | 973 } |
950 | 974 |
951 } } // namespace v8::internal | 975 } } // namespace v8::internal |
OLD | NEW |