| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 Address HandleScope::current_next_address(Isolate* isolate) { | 117 Address HandleScope::current_next_address(Isolate* isolate) { |
| 118 return reinterpret_cast<Address>(&isolate->handle_scope_data()->next); | 118 return reinterpret_cast<Address>(&isolate->handle_scope_data()->next); |
| 119 } | 119 } |
| 120 | 120 |
| 121 | 121 |
| 122 Address HandleScope::current_limit_address(Isolate* isolate) { | 122 Address HandleScope::current_limit_address(Isolate* isolate) { |
| 123 return reinterpret_cast<Address>(&isolate->handle_scope_data()->limit); | 123 return reinterpret_cast<Address>(&isolate->handle_scope_data()->limit); |
| 124 } | 124 } |
| 125 | 125 |
| 126 | 126 |
| 127 Handle<FixedArray> AddKeysFromJSArray(Handle<FixedArray> content, | |
| 128 Handle<JSArray> array) { | |
| 129 CALL_HEAP_FUNCTION(content->GetIsolate(), | |
| 130 content->AddKeysFromJSArray(*array), FixedArray); | |
| 131 } | |
| 132 | |
| 133 | |
| 134 Handle<FixedArray> UnionOfKeys(Handle<FixedArray> first, | |
| 135 Handle<FixedArray> second) { | |
| 136 CALL_HEAP_FUNCTION(first->GetIsolate(), | |
| 137 first->UnionOfKeys(*second), FixedArray); | |
| 138 } | |
| 139 | |
| 140 | |
| 141 Handle<JSGlobalProxy> ReinitializeJSGlobalProxy( | 127 Handle<JSGlobalProxy> ReinitializeJSGlobalProxy( |
| 142 Handle<JSFunction> constructor, | 128 Handle<JSFunction> constructor, |
| 143 Handle<JSGlobalProxy> global) { | 129 Handle<JSGlobalProxy> global) { |
| 144 CALL_HEAP_FUNCTION( | 130 CALL_HEAP_FUNCTION( |
| 145 constructor->GetIsolate(), | 131 constructor->GetIsolate(), |
| 146 constructor->GetHeap()->ReinitializeJSGlobalProxy(*constructor, *global), | 132 constructor->GetHeap()->ReinitializeJSGlobalProxy(*constructor, *global), |
| 147 JSGlobalProxy); | 133 JSGlobalProxy); |
| 148 } | 134 } |
| 149 | 135 |
| 150 | 136 |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 if (p->IsJSProxy()) { | 491 if (p->IsJSProxy()) { |
| 506 Handle<JSProxy> proxy(JSProxy::cast(*p), isolate); | 492 Handle<JSProxy> proxy(JSProxy::cast(*p), isolate); |
| 507 Handle<Object> args[] = { proxy }; | 493 Handle<Object> args[] = { proxy }; |
| 508 Handle<Object> names = Execution::Call(isolate, | 494 Handle<Object> names = Execution::Call(isolate, |
| 509 isolate->proxy_enumerate(), | 495 isolate->proxy_enumerate(), |
| 510 object, | 496 object, |
| 511 ARRAY_SIZE(args), | 497 ARRAY_SIZE(args), |
| 512 args, | 498 args, |
| 513 threw); | 499 threw); |
| 514 if (*threw) return content; | 500 if (*threw) return content; |
| 515 content = AddKeysFromJSArray(content, Handle<JSArray>::cast(names)); | 501 content = FixedArray::AddKeysFromJSArray(content, |
| 502 Handle<JSArray>::cast(names)); |
| 516 break; | 503 break; |
| 517 } | 504 } |
| 518 | 505 |
| 519 Handle<JSObject> current(JSObject::cast(*p), isolate); | 506 Handle<JSObject> current(JSObject::cast(*p), isolate); |
| 520 | 507 |
| 521 // Check access rights if required. | 508 // Check access rights if required. |
| 522 if (current->IsAccessCheckNeeded() && | 509 if (current->IsAccessCheckNeeded() && |
| 523 !isolate->MayNamedAccessWrapper(current, | 510 !isolate->MayNamedAccessWrapper(current, |
| 524 isolate->factory()->undefined_value(), | 511 isolate->factory()->undefined_value(), |
| 525 v8::ACCESS_KEYS)) { | 512 v8::ACCESS_KEYS)) { |
| 526 isolate->ReportFailedAccessCheckWrapper(current, v8::ACCESS_KEYS); | 513 isolate->ReportFailedAccessCheckWrapper(current, v8::ACCESS_KEYS); |
| 527 if (isolate->has_scheduled_exception()) { | 514 if (isolate->has_scheduled_exception()) { |
| 528 isolate->PromoteScheduledException(); | 515 isolate->PromoteScheduledException(); |
| 529 *threw = true; | 516 *threw = true; |
| 530 } | 517 } |
| 531 break; | 518 break; |
| 532 } | 519 } |
| 533 | 520 |
| 534 // Compute the element keys. | 521 // Compute the element keys. |
| 535 Handle<FixedArray> element_keys = | 522 Handle<FixedArray> element_keys = |
| 536 isolate->factory()->NewFixedArray(current->NumberOfEnumElements()); | 523 isolate->factory()->NewFixedArray(current->NumberOfEnumElements()); |
| 537 current->GetEnumElementKeys(*element_keys); | 524 current->GetEnumElementKeys(*element_keys); |
| 538 content = UnionOfKeys(content, element_keys); | 525 content = FixedArray::UnionOfKeys(content, element_keys); |
| 539 ASSERT(ContainsOnlyValidKeys(content)); | 526 ASSERT(ContainsOnlyValidKeys(content)); |
| 540 | 527 |
| 541 // Add the element keys from the interceptor. | 528 // Add the element keys from the interceptor. |
| 542 if (current->HasIndexedInterceptor()) { | 529 if (current->HasIndexedInterceptor()) { |
| 543 v8::Handle<v8::Array> result = | 530 v8::Handle<v8::Array> result = |
| 544 GetKeysForIndexedInterceptor(object, current); | 531 GetKeysForIndexedInterceptor(object, current); |
| 545 if (!result.IsEmpty()) | 532 if (!result.IsEmpty()) |
| 546 content = AddKeysFromJSArray(content, v8::Utils::OpenHandle(*result)); | 533 content = FixedArray::AddKeysFromJSArray( |
| 534 content, v8::Utils::OpenHandle(*result)); |
| 547 ASSERT(ContainsOnlyValidKeys(content)); | 535 ASSERT(ContainsOnlyValidKeys(content)); |
| 548 } | 536 } |
| 549 | 537 |
| 550 // We can cache the computed property keys if access checks are | 538 // We can cache the computed property keys if access checks are |
| 551 // not needed and no interceptors are involved. | 539 // not needed and no interceptors are involved. |
| 552 // | 540 // |
| 553 // We do not use the cache if the object has elements and | 541 // We do not use the cache if the object has elements and |
| 554 // therefore it does not make sense to cache the property names | 542 // therefore it does not make sense to cache the property names |
| 555 // for arguments objects. Arguments objects will always have | 543 // for arguments objects. Arguments objects will always have |
| 556 // elements. | 544 // elements. |
| 557 // Wrapped strings have elements, but don't have an elements | 545 // Wrapped strings have elements, but don't have an elements |
| 558 // array or dictionary. So the fast inline test for whether to | 546 // array or dictionary. So the fast inline test for whether to |
| 559 // use the cache says yes, so we should not create a cache. | 547 // use the cache says yes, so we should not create a cache. |
| 560 bool cache_enum_keys = | 548 bool cache_enum_keys = |
| 561 ((current->map()->constructor() != *arguments_function) && | 549 ((current->map()->constructor() != *arguments_function) && |
| 562 !current->IsJSValue() && | 550 !current->IsJSValue() && |
| 563 !current->IsAccessCheckNeeded() && | 551 !current->IsAccessCheckNeeded() && |
| 564 !current->HasNamedInterceptor() && | 552 !current->HasNamedInterceptor() && |
| 565 !current->HasIndexedInterceptor()); | 553 !current->HasIndexedInterceptor()); |
| 566 // Compute the property keys and cache them if possible. | 554 // Compute the property keys and cache them if possible. |
| 567 content = | 555 content = FixedArray::UnionOfKeys( |
| 568 UnionOfKeys(content, GetEnumPropertyKeys(current, cache_enum_keys)); | 556 content, GetEnumPropertyKeys(current, cache_enum_keys)); |
| 569 ASSERT(ContainsOnlyValidKeys(content)); | 557 ASSERT(ContainsOnlyValidKeys(content)); |
| 570 | 558 |
| 571 // Add the property keys from the interceptor. | 559 // Add the property keys from the interceptor. |
| 572 if (current->HasNamedInterceptor()) { | 560 if (current->HasNamedInterceptor()) { |
| 573 v8::Handle<v8::Array> result = | 561 v8::Handle<v8::Array> result = |
| 574 GetKeysForNamedInterceptor(object, current); | 562 GetKeysForNamedInterceptor(object, current); |
| 575 if (!result.IsEmpty()) | 563 if (!result.IsEmpty()) |
| 576 content = AddKeysFromJSArray(content, v8::Utils::OpenHandle(*result)); | 564 content = FixedArray::AddKeysFromJSArray( |
| 565 content, v8::Utils::OpenHandle(*result)); |
| 577 ASSERT(ContainsOnlyValidKeys(content)); | 566 ASSERT(ContainsOnlyValidKeys(content)); |
| 578 } | 567 } |
| 579 | 568 |
| 580 // If we only want local properties we bail out after the first | 569 // If we only want local properties we bail out after the first |
| 581 // iteration. | 570 // iteration. |
| 582 if (type == LOCAL_ONLY) | 571 if (type == LOCAL_ONLY) |
| 583 break; | 572 break; |
| 584 } | 573 } |
| 585 return content; | 574 return content; |
| 586 } | 575 } |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 Handle<Code> code) { | 743 Handle<Code> code) { |
| 755 heap->EnsureWeakObjectToCodeTable(); | 744 heap->EnsureWeakObjectToCodeTable(); |
| 756 Handle<DependentCode> dep(heap->LookupWeakObjectToCodeDependency(*object)); | 745 Handle<DependentCode> dep(heap->LookupWeakObjectToCodeDependency(*object)); |
| 757 dep = DependentCode::Insert(dep, DependentCode::kWeaklyEmbeddedGroup, code); | 746 dep = DependentCode::Insert(dep, DependentCode::kWeaklyEmbeddedGroup, code); |
| 758 CALL_HEAP_FUNCTION_VOID(heap->isolate(), | 747 CALL_HEAP_FUNCTION_VOID(heap->isolate(), |
| 759 heap->AddWeakObjectToCodeDependency(*object, *dep)); | 748 heap->AddWeakObjectToCodeDependency(*object, *dep)); |
| 760 } | 749 } |
| 761 | 750 |
| 762 | 751 |
| 763 } } // namespace v8::internal | 752 } } // namespace v8::internal |
| OLD | NEW |