| 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 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 Handle<Object> GetScriptNameOrSourceURL(Handle<Script> script) { | 399 Handle<Object> GetScriptNameOrSourceURL(Handle<Script> script) { |
| 400 Isolate* isolate = script->GetIsolate(); | 400 Isolate* isolate = script->GetIsolate(); |
| 401 Handle<String> name_or_source_url_key = | 401 Handle<String> name_or_source_url_key = |
| 402 isolate->factory()->InternalizeOneByteString( | 402 isolate->factory()->InternalizeOneByteString( |
| 403 STATIC_ASCII_VECTOR("nameOrSourceURL")); | 403 STATIC_ASCII_VECTOR("nameOrSourceURL")); |
| 404 Handle<JSValue> script_wrapper = GetScriptWrapper(script); | 404 Handle<JSValue> script_wrapper = GetScriptWrapper(script); |
| 405 Handle<Object> property = | 405 Handle<Object> property = |
| 406 Object::GetProperty(script_wrapper, name_or_source_url_key); | 406 Object::GetProperty(script_wrapper, name_or_source_url_key); |
| 407 ASSERT(property->IsJSFunction()); | 407 ASSERT(property->IsJSFunction()); |
| 408 Handle<JSFunction> method = Handle<JSFunction>::cast(property); | 408 Handle<JSFunction> method = Handle<JSFunction>::cast(property); |
| 409 bool caught_exception; | 409 Handle<Object> result; |
| 410 Handle<Object> result = Execution::TryCall(method, script_wrapper, 0, | 410 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
| 411 NULL, &caught_exception); | 411 isolate, result, |
| 412 if (caught_exception) { | 412 Execution::TryCall(method, script_wrapper, 0, NULL), |
| 413 result = isolate->factory()->undefined_value(); | 413 isolate->factory()->undefined_value()); |
| 414 } | |
| 415 return result; | 414 return result; |
| 416 } | 415 } |
| 417 | 416 |
| 418 | 417 |
| 419 static bool ContainsOnlyValidKeys(Handle<FixedArray> array) { | 418 static bool ContainsOnlyValidKeys(Handle<FixedArray> array) { |
| 420 int len = array->length(); | 419 int len = array->length(); |
| 421 for (int i = 0; i < len; i++) { | 420 for (int i = 0; i < len; i++) { |
| 422 Object* e = array->get(i); | 421 Object* e = array->get(i); |
| 423 if (!(e->IsString() || e->IsNumber())) return false; | 422 if (!(e->IsString() || e->IsNumber())) return false; |
| 424 } | 423 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 438 JSFunction::cast(arguments_boilerplate->map()->constructor()), | 437 JSFunction::cast(arguments_boilerplate->map()->constructor()), |
| 439 isolate); | 438 isolate); |
| 440 | 439 |
| 441 // Only collect keys if access is permitted. | 440 // Only collect keys if access is permitted. |
| 442 for (Handle<Object> p = object; | 441 for (Handle<Object> p = object; |
| 443 *p != isolate->heap()->null_value(); | 442 *p != isolate->heap()->null_value(); |
| 444 p = Handle<Object>(p->GetPrototype(isolate), isolate)) { | 443 p = Handle<Object>(p->GetPrototype(isolate), isolate)) { |
| 445 if (p->IsJSProxy()) { | 444 if (p->IsJSProxy()) { |
| 446 Handle<JSProxy> proxy(JSProxy::cast(*p), isolate); | 445 Handle<JSProxy> proxy(JSProxy::cast(*p), isolate); |
| 447 Handle<Object> args[] = { proxy }; | 446 Handle<Object> args[] = { proxy }; |
| 448 bool has_pending_exception; | 447 Handle<Object> names; |
| 449 Handle<Object> names = Execution::Call(isolate, | 448 ASSIGN_RETURN_ON_EXCEPTION( |
| 450 isolate->proxy_enumerate(), | 449 isolate, names, |
| 451 object, | 450 Execution::Call(isolate, |
| 452 ARRAY_SIZE(args), | 451 isolate->proxy_enumerate(), |
| 453 args, | 452 object, |
| 454 &has_pending_exception); | 453 ARRAY_SIZE(args), |
| 455 if (has_pending_exception) return MaybeHandle<FixedArray>(); | 454 args), |
| 455 FixedArray); |
| 456 ASSIGN_RETURN_ON_EXCEPTION( | 456 ASSIGN_RETURN_ON_EXCEPTION( |
| 457 isolate, content, | 457 isolate, content, |
| 458 FixedArray::AddKeysFromJSArray(content, Handle<JSArray>::cast(names)), | 458 FixedArray::AddKeysFromJSArray( |
| 459 content, Handle<JSArray>::cast(names)), |
| 459 FixedArray); | 460 FixedArray); |
| 460 break; | 461 break; |
| 461 } | 462 } |
| 462 | 463 |
| 463 Handle<JSObject> current(JSObject::cast(*p), isolate); | 464 Handle<JSObject> current(JSObject::cast(*p), isolate); |
| 464 | 465 |
| 465 // Check access rights if required. | 466 // Check access rights if required. |
| 466 if (current->IsAccessCheckNeeded() && | 467 if (current->IsAccessCheckNeeded() && |
| 467 !isolate->MayNamedAccessWrapper(current, | 468 !isolate->MayNamedAccessWrapper(current, |
| 468 isolate->factory()->undefined_value(), | 469 isolate->factory()->undefined_value(), |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 isolate, content, | 530 isolate, content, |
| 530 FixedArray::AddKeysFromJSArray( | 531 FixedArray::AddKeysFromJSArray( |
| 531 content, v8::Utils::OpenHandle(*result)), | 532 content, v8::Utils::OpenHandle(*result)), |
| 532 FixedArray); | 533 FixedArray); |
| 533 } | 534 } |
| 534 ASSERT(ContainsOnlyValidKeys(content)); | 535 ASSERT(ContainsOnlyValidKeys(content)); |
| 535 } | 536 } |
| 536 | 537 |
| 537 // If we only want local properties we bail out after the first | 538 // If we only want local properties we bail out after the first |
| 538 // iteration. | 539 // iteration. |
| 539 if (type == LOCAL_ONLY) | 540 if (type == LOCAL_ONLY) break; |
| 540 break; | |
| 541 } | 541 } |
| 542 return content; | 542 return content; |
| 543 } | 543 } |
| 544 | 544 |
| 545 | 545 |
| 546 MaybeHandle<JSArray> GetKeysFor(Handle<JSReceiver> object) { | |
| 547 Isolate* isolate = object->GetIsolate(); | |
| 548 isolate->counters()->for_in()->Increment(); | |
| 549 Handle<FixedArray> elements; | |
| 550 ASSIGN_RETURN_ON_EXCEPTION( | |
| 551 isolate, elements, | |
| 552 GetKeysInFixedArrayFor(object, INCLUDE_PROTOS), | |
| 553 JSArray); | |
| 554 return isolate->factory()->NewJSArrayWithElements(elements); | |
| 555 } | |
| 556 | |
| 557 | |
| 558 Handle<FixedArray> ReduceFixedArrayTo(Handle<FixedArray> array, int length) { | 546 Handle<FixedArray> ReduceFixedArrayTo(Handle<FixedArray> array, int length) { |
| 559 ASSERT(array->length() >= length); | 547 ASSERT(array->length() >= length); |
| 560 if (array->length() == length) return array; | 548 if (array->length() == length) return array; |
| 561 | 549 |
| 562 Handle<FixedArray> new_array = | 550 Handle<FixedArray> new_array = |
| 563 array->GetIsolate()->factory()->NewFixedArray(length); | 551 array->GetIsolate()->factory()->NewFixedArray(length); |
| 564 for (int i = 0; i < length; ++i) new_array->set(i, array->get(i)); | 552 for (int i = 0; i < length; ++i) new_array->set(i, array->get(i)); |
| 565 return new_array; | 553 return new_array; |
| 566 } | 554 } |
| 567 | 555 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 714 Handle<Code> code) { | 702 Handle<Code> code) { |
| 715 heap->EnsureWeakObjectToCodeTable(); | 703 heap->EnsureWeakObjectToCodeTable(); |
| 716 Handle<DependentCode> dep(heap->LookupWeakObjectToCodeDependency(*object)); | 704 Handle<DependentCode> dep(heap->LookupWeakObjectToCodeDependency(*object)); |
| 717 dep = DependentCode::Insert(dep, DependentCode::kWeaklyEmbeddedGroup, code); | 705 dep = DependentCode::Insert(dep, DependentCode::kWeaklyEmbeddedGroup, code); |
| 718 CALL_HEAP_FUNCTION_VOID(heap->isolate(), | 706 CALL_HEAP_FUNCTION_VOID(heap->isolate(), |
| 719 heap->AddWeakObjectToCodeDependency(*object, *dep)); | 707 heap->AddWeakObjectToCodeDependency(*object, *dep)); |
| 720 } | 708 } |
| 721 | 709 |
| 722 | 710 |
| 723 } } // namespace v8::internal | 711 } } // namespace v8::internal |
| OLD | NEW |