| 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 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 obj->SetPrototype(*value, skip_hidden_prototypes), Object); | 415 obj->SetPrototype(*value, skip_hidden_prototypes), Object); |
| 416 } | 416 } |
| 417 | 417 |
| 418 | 418 |
| 419 Handle<Object> PreventExtensions(Handle<JSObject> object) { | 419 Handle<Object> PreventExtensions(Handle<JSObject> object) { |
| 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 JSObject::HiddenPropertiesFlag flag) { |
| 426 Isolate* isolate = obj->GetIsolate(); | 426 CALL_HEAP_FUNCTION(obj->GetIsolate(), |
| 427 Object* holder = obj->BypassGlobalProxy(); | 427 obj->GetHiddenProperties(flag), |
| 428 if (holder->IsUndefined()) return isolate->factory()->undefined_value(); | 428 Object); |
| 429 obj = Handle<JSObject>(JSObject::cast(holder), isolate); | |
| 430 | |
| 431 if (obj->HasFastProperties()) { | |
| 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); | |
| 462 } | 429 } |
| 463 | 430 |
| 464 | 431 |
| 432 int GetIdentityHash(Handle<JSObject> obj) { |
| 433 CALL_AND_RETRY(obj->GetIsolate(), |
| 434 obj->GetIdentityHash(JSObject::ALLOW_CREATION), |
| 435 return Smi::cast(__object__)->value(), |
| 436 return 0); |
| 437 } |
| 438 |
| 439 |
| 465 Handle<Object> DeleteElement(Handle<JSObject> obj, | 440 Handle<Object> DeleteElement(Handle<JSObject> obj, |
| 466 uint32_t index) { | 441 uint32_t index) { |
| 467 CALL_HEAP_FUNCTION(obj->GetIsolate(), | 442 CALL_HEAP_FUNCTION(obj->GetIsolate(), |
| 468 obj->DeleteElement(index, JSObject::NORMAL_DELETION), | 443 obj->DeleteElement(index, JSObject::NORMAL_DELETION), |
| 469 Object); | 444 Object); |
| 470 } | 445 } |
| 471 | 446 |
| 472 | 447 |
| 473 Handle<Object> DeleteProperty(Handle<JSObject> obj, | 448 Handle<Object> DeleteProperty(Handle<JSObject> obj, |
| 474 Handle<String> prop) { | 449 Handle<String> prop) { |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 901 } else { | 876 } else { |
| 902 int num_enum = object->NumberOfEnumProperties(); | 877 int num_enum = object->NumberOfEnumProperties(); |
| 903 Handle<FixedArray> storage = isolate->factory()->NewFixedArray(num_enum); | 878 Handle<FixedArray> storage = isolate->factory()->NewFixedArray(num_enum); |
| 904 Handle<FixedArray> sort_array = isolate->factory()->NewFixedArray(num_enum); | 879 Handle<FixedArray> sort_array = isolate->factory()->NewFixedArray(num_enum); |
| 905 object->property_dictionary()->CopyEnumKeysTo(*storage, *sort_array); | 880 object->property_dictionary()->CopyEnumKeysTo(*storage, *sort_array); |
| 906 return storage; | 881 return storage; |
| 907 } | 882 } |
| 908 } | 883 } |
| 909 | 884 |
| 910 | 885 |
| 886 Handle<ObjectHashTable> PutIntoObjectHashTable(Handle<ObjectHashTable> table, |
| 887 Handle<JSObject> key, |
| 888 Handle<Object> value) { |
| 889 CALL_HEAP_FUNCTION(table->GetIsolate(), |
| 890 table->Put(*key, *value), |
| 891 ObjectHashTable); |
| 892 } |
| 893 |
| 894 |
| 911 bool EnsureCompiled(Handle<SharedFunctionInfo> shared, | 895 bool EnsureCompiled(Handle<SharedFunctionInfo> shared, |
| 912 ClearExceptionFlag flag) { | 896 ClearExceptionFlag flag) { |
| 913 return shared->is_compiled() || CompileLazyShared(shared, flag); | 897 return shared->is_compiled() || CompileLazyShared(shared, flag); |
| 914 } | 898 } |
| 915 | 899 |
| 916 | 900 |
| 917 static bool CompileLazyHelper(CompilationInfo* info, | 901 static bool CompileLazyHelper(CompilationInfo* info, |
| 918 ClearExceptionFlag flag) { | 902 ClearExceptionFlag flag) { |
| 919 // Compile the source information to a code object. | 903 // Compile the source information to a code object. |
| 920 ASSERT(info->IsOptimizing() || !info->shared_info()->is_compiled()); | 904 ASSERT(info->IsOptimizing() || !info->shared_info()->is_compiled()); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 966 | 950 |
| 967 bool CompileOptimized(Handle<JSFunction> function, | 951 bool CompileOptimized(Handle<JSFunction> function, |
| 968 int osr_ast_id, | 952 int osr_ast_id, |
| 969 ClearExceptionFlag flag) { | 953 ClearExceptionFlag flag) { |
| 970 CompilationInfo info(function); | 954 CompilationInfo info(function); |
| 971 info.SetOptimizing(osr_ast_id); | 955 info.SetOptimizing(osr_ast_id); |
| 972 return CompileLazyHelper(&info, flag); | 956 return CompileLazyHelper(&info, flag); |
| 973 } | 957 } |
| 974 | 958 |
| 975 } } // namespace v8::internal | 959 } } // namespace v8::internal |
| OLD | NEW |