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 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 bool create_if_needed) { |
426 Isolate* isolate = obj->GetIsolate(); | 426 CALL_HEAP_FUNCTION(obj->GetIsolate(), |
427 Object* holder = obj->BypassGlobalProxy(); | 427 obj->GetHiddenProperties(create_if_needed), |
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 Handle<Smi> GetIdentityHash(Handle<JSObject> obj) { | |
433 CALL_HEAP_FUNCTION(obj->GetIsolate(), obj->GetIdentityHash(), Smi); | |
Vitaly Repeshko
2011/07/26 13:53:14
Creating a handle for a Smi is a waste. Use someth
Michael Starzinger
2011/07/26 22:30:23
Fixed.
| |
434 } | |
435 | |
436 | |
465 Handle<Object> DeleteElement(Handle<JSObject> obj, | 437 Handle<Object> DeleteElement(Handle<JSObject> obj, |
466 uint32_t index) { | 438 uint32_t index) { |
467 CALL_HEAP_FUNCTION(obj->GetIsolate(), | 439 CALL_HEAP_FUNCTION(obj->GetIsolate(), |
468 obj->DeleteElement(index, JSObject::NORMAL_DELETION), | 440 obj->DeleteElement(index, JSObject::NORMAL_DELETION), |
469 Object); | 441 Object); |
470 } | 442 } |
471 | 443 |
472 | 444 |
473 Handle<Object> DeleteProperty(Handle<JSObject> obj, | 445 Handle<Object> DeleteProperty(Handle<JSObject> obj, |
474 Handle<String> prop) { | 446 Handle<String> prop) { |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
966 | 938 |
967 bool CompileOptimized(Handle<JSFunction> function, | 939 bool CompileOptimized(Handle<JSFunction> function, |
968 int osr_ast_id, | 940 int osr_ast_id, |
969 ClearExceptionFlag flag) { | 941 ClearExceptionFlag flag) { |
970 CompilationInfo info(function); | 942 CompilationInfo info(function); |
971 info.SetOptimizing(osr_ast_id); | 943 info.SetOptimizing(osr_ast_id); |
972 return CompileLazyHelper(&info, flag); | 944 return CompileLazyHelper(&info, flag); |
973 } | 945 } |
974 | 946 |
975 } } // namespace v8::internal | 947 } } // namespace v8::internal |
OLD | NEW |