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 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
505 CreateObjectLiteralBoilerplate( | 505 CreateObjectLiteralBoilerplate( |
506 isolate, | 506 isolate, |
507 literals, | 507 literals, |
508 constant_properties, | 508 constant_properties, |
509 should_have_fast_elements, | 509 should_have_fast_elements, |
510 has_function_literal)); | 510 has_function_literal)); |
511 boilerplate = Handle<JSObject>::cast(raw_boilerplate); | 511 boilerplate = Handle<JSObject>::cast(raw_boilerplate); |
512 | 512 |
513 AllocationSiteCreationContext creation_context(isolate); | 513 AllocationSiteCreationContext creation_context(isolate); |
514 site = creation_context.EnterNewScope(); | 514 site = creation_context.EnterNewScope(); |
515 RETURN_IF_EMPTY_HANDLE(isolate, | 515 RETURN_FAILURE_ON_EXCEPTION( |
516 JSObject::DeepWalk(boilerplate, &creation_context)); | 516 isolate, |
517 JSObject::DeepWalk(boilerplate, &creation_context)); | |
517 creation_context.ExitScope(site, boilerplate); | 518 creation_context.ExitScope(site, boilerplate); |
518 | 519 |
519 // Update the functions literal and return the boilerplate. | 520 // Update the functions literal and return the boilerplate. |
520 literals->set(literals_index, *site); | 521 literals->set(literals_index, *site); |
521 } else { | 522 } else { |
522 site = Handle<AllocationSite>::cast(literal_site); | 523 site = Handle<AllocationSite>::cast(literal_site); |
523 boilerplate = Handle<JSObject>(JSObject::cast(site->transition_info()), | 524 boilerplate = Handle<JSObject>(JSObject::cast(site->transition_info()), |
524 isolate); | 525 isolate); |
525 } | 526 } |
526 | 527 |
527 AllocationSiteUsageContext usage_context(isolate, site, true); | 528 AllocationSiteUsageContext usage_context(isolate, site, true); |
528 usage_context.EnterNewScope(); | 529 usage_context.EnterNewScope(); |
529 Handle<Object> copy = JSObject::DeepCopy(boilerplate, &usage_context); | 530 MaybeHandle<Object> maybe_copy = JSObject::DeepCopy( |
531 boilerplate, &usage_context); | |
530 usage_context.ExitScope(site, boilerplate); | 532 usage_context.ExitScope(site, boilerplate); |
531 RETURN_IF_EMPTY_HANDLE(isolate, copy); | 533 Handle<Object> copy; |
534 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, copy, maybe_copy); | |
532 return *copy; | 535 return *copy; |
533 } | 536 } |
534 | 537 |
535 | 538 |
536 MUST_USE_RESULT static MaybeHandle<AllocationSite> GetLiteralAllocationSite( | 539 MUST_USE_RESULT static MaybeHandle<AllocationSite> GetLiteralAllocationSite( |
537 Isolate* isolate, | 540 Isolate* isolate, |
538 Handle<FixedArray> literals, | 541 Handle<FixedArray> literals, |
539 int literals_index, | 542 int literals_index, |
540 Handle<FixedArray> elements) { | 543 Handle<FixedArray> elements) { |
541 // Check if boilerplate exists. If not, create it first. | 544 // Check if boilerplate exists. If not, create it first. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
579 GetLiteralAllocationSite(isolate, literals, literals_index, elements), | 582 GetLiteralAllocationSite(isolate, literals, literals_index, elements), |
580 JSObject); | 583 JSObject); |
581 | 584 |
582 bool enable_mementos = (flags & ArrayLiteral::kDisableMementos) == 0; | 585 bool enable_mementos = (flags & ArrayLiteral::kDisableMementos) == 0; |
583 Handle<JSObject> boilerplate(JSObject::cast(site->transition_info())); | 586 Handle<JSObject> boilerplate(JSObject::cast(site->transition_info())); |
584 AllocationSiteUsageContext usage_context(isolate, site, enable_mementos); | 587 AllocationSiteUsageContext usage_context(isolate, site, enable_mementos); |
585 usage_context.EnterNewScope(); | 588 usage_context.EnterNewScope(); |
586 JSObject::DeepCopyHints hints = (flags & ArrayLiteral::kShallowElements) == 0 | 589 JSObject::DeepCopyHints hints = (flags & ArrayLiteral::kShallowElements) == 0 |
587 ? JSObject::kNoHints | 590 ? JSObject::kNoHints |
588 : JSObject::kObjectIsShallowArray; | 591 : JSObject::kObjectIsShallowArray; |
589 Handle<JSObject> copy = JSObject::DeepCopy(boilerplate, &usage_context, | 592 MaybeHandle<JSObject> copy = JSObject::DeepCopy(boilerplate, &usage_context, |
590 hints); | 593 hints); |
591 usage_context.ExitScope(site, boilerplate); | 594 usage_context.ExitScope(site, boilerplate); |
592 return copy; | 595 return copy; |
593 } | 596 } |
594 | 597 |
595 | 598 |
596 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_CreateArrayLiteral) { | 599 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_CreateArrayLiteral) { |
597 HandleScope scope(isolate); | 600 HandleScope scope(isolate); |
598 ASSERT(args.length() == 4); | 601 ASSERT(args.length() == 4); |
599 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); | 602 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); |
600 CONVERT_SMI_ARG_CHECKED(literals_index, 1); | 603 CONVERT_SMI_ARG_CHECKED(literals_index, 1); |
(...skipping 1151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1752 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 1); | 1755 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 1); |
1753 if (obj->IsAccessCheckNeeded() && | 1756 if (obj->IsAccessCheckNeeded() && |
1754 !isolate->MayNamedAccess( | 1757 !isolate->MayNamedAccess( |
1755 obj, isolate->factory()->proto_string(), v8::ACCESS_SET)) { | 1758 obj, isolate->factory()->proto_string(), v8::ACCESS_SET)) { |
1756 isolate->ReportFailedAccessCheck(obj, v8::ACCESS_SET); | 1759 isolate->ReportFailedAccessCheck(obj, v8::ACCESS_SET); |
1757 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); | 1760 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); |
1758 return isolate->heap()->undefined_value(); | 1761 return isolate->heap()->undefined_value(); |
1759 } | 1762 } |
1760 if (obj->map()->is_observed()) { | 1763 if (obj->map()->is_observed()) { |
1761 Handle<Object> old_value = GetPrototypeSkipHiddenPrototypes(isolate, obj); | 1764 Handle<Object> old_value = GetPrototypeSkipHiddenPrototypes(isolate, obj); |
1762 | 1765 Handle<Object> result; |
1763 Handle<Object> result = JSObject::SetPrototype(obj, prototype, true); | 1766 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
1764 RETURN_IF_EMPTY_HANDLE(isolate, result); | 1767 isolate, result, |
1768 JSObject::SetPrototype(obj, prototype, true)); | |
1765 | 1769 |
1766 Handle<Object> new_value = GetPrototypeSkipHiddenPrototypes(isolate, obj); | 1770 Handle<Object> new_value = GetPrototypeSkipHiddenPrototypes(isolate, obj); |
1767 if (!new_value->SameValue(*old_value)) { | 1771 if (!new_value->SameValue(*old_value)) { |
1768 JSObject::EnqueueChangeRecord(obj, "setPrototype", | 1772 JSObject::EnqueueChangeRecord(obj, "setPrototype", |
1769 isolate->factory()->proto_string(), | 1773 isolate->factory()->proto_string(), |
1770 old_value); | 1774 old_value); |
1771 } | 1775 } |
1772 return *result; | 1776 return *result; |
1773 } | 1777 } |
1774 Handle<Object> result = JSObject::SetPrototype(obj, prototype, true); | 1778 Handle<Object> result; |
1775 RETURN_IF_EMPTY_HANDLE(isolate, result); | 1779 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
1780 isolate, result, | |
1781 JSObject::SetPrototype(obj, prototype, true)); | |
1776 return *result; | 1782 return *result; |
1777 } | 1783 } |
1778 | 1784 |
1779 | 1785 |
1780 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsInPrototypeChain) { | 1786 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsInPrototypeChain) { |
1781 HandleScope shs(isolate); | 1787 HandleScope shs(isolate); |
1782 ASSERT(args.length() == 2); | 1788 ASSERT(args.length() == 2); |
1783 // See ECMA-262, section 15.3.5.3, page 88 (steps 5 - 8). | 1789 // See ECMA-262, section 15.3.5.3, page 88 (steps 5 - 8). |
1784 CONVERT_ARG_HANDLE_CHECKED(Object, O, 0); | 1790 CONVERT_ARG_HANDLE_CHECKED(Object, O, 0); |
1785 CONVERT_ARG_HANDLE_CHECKED(Object, V, 1); | 1791 CONVERT_ARG_HANDLE_CHECKED(Object, V, 1); |
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2593 ASSERT(args.length() == 4); | 2599 ASSERT(args.length() == 4); |
2594 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 0); | 2600 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 0); |
2595 CONVERT_ARG_HANDLE_CHECKED(String, subject, 1); | 2601 CONVERT_ARG_HANDLE_CHECKED(String, subject, 1); |
2596 // Due to the way the JS calls are constructed this must be less than the | 2602 // Due to the way the JS calls are constructed this must be less than the |
2597 // length of a string, i.e. it is always a Smi. We check anyway for security. | 2603 // length of a string, i.e. it is always a Smi. We check anyway for security. |
2598 CONVERT_SMI_ARG_CHECKED(index, 2); | 2604 CONVERT_SMI_ARG_CHECKED(index, 2); |
2599 CONVERT_ARG_HANDLE_CHECKED(JSArray, last_match_info, 3); | 2605 CONVERT_ARG_HANDLE_CHECKED(JSArray, last_match_info, 3); |
2600 RUNTIME_ASSERT(index >= 0); | 2606 RUNTIME_ASSERT(index >= 0); |
2601 RUNTIME_ASSERT(index <= subject->length()); | 2607 RUNTIME_ASSERT(index <= subject->length()); |
2602 isolate->counters()->regexp_entry_runtime()->Increment(); | 2608 isolate->counters()->regexp_entry_runtime()->Increment(); |
2603 Handle<Object> result = RegExpImpl::Exec(regexp, | 2609 Handle<Object> result; |
2604 subject, | 2610 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
2605 index, | 2611 isolate, result, |
2606 last_match_info); | 2612 RegExpImpl::Exec(regexp, subject, index, last_match_info)); |
2607 RETURN_IF_EMPTY_HANDLE(isolate, result); | |
2608 return *result; | 2613 return *result; |
2609 } | 2614 } |
2610 | 2615 |
2611 | 2616 |
2612 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_RegExpConstructResult) { | 2617 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_RegExpConstructResult) { |
2613 HandleScope handle_scope(isolate); | 2618 HandleScope handle_scope(isolate); |
2614 ASSERT(args.length() == 3); | 2619 ASSERT(args.length() == 3); |
2615 CONVERT_SMI_ARG_CHECKED(size, 0); | 2620 CONVERT_SMI_ARG_CHECKED(size, 0); |
2616 RUNTIME_ASSERT(size >= 0 && size <= FixedArray::kMaxLength); | 2621 RUNTIME_ASSERT(size >= 0 && size <= FixedArray::kMaxLength); |
2617 CONVERT_ARG_HANDLE_CHECKED(Object, index, 1); | 2622 CONVERT_ARG_HANDLE_CHECKED(Object, index, 1); |
(...skipping 12219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
14837 to_kind = GetHoleyElementsKind(to_kind); | 14842 to_kind = GetHoleyElementsKind(to_kind); |
14838 // Update the allocation site info to reflect the advice alteration. | 14843 // Update the allocation site info to reflect the advice alteration. |
14839 site->SetElementsKind(to_kind); | 14844 site->SetElementsKind(to_kind); |
14840 } | 14845 } |
14841 | 14846 |
14842 // We should allocate with an initial map that reflects the allocation site | 14847 // We should allocate with an initial map that reflects the allocation site |
14843 // advice. Therefore we use AllocateJSObjectFromMap instead of passing | 14848 // advice. Therefore we use AllocateJSObjectFromMap instead of passing |
14844 // the constructor. | 14849 // the constructor. |
14845 Handle<Map> initial_map(constructor->initial_map(), isolate); | 14850 Handle<Map> initial_map(constructor->initial_map(), isolate); |
14846 if (to_kind != initial_map->elements_kind()) { | 14851 if (to_kind != initial_map->elements_kind()) { |
14847 initial_map = Map::AsElementsKind(initial_map, to_kind); | 14852 initial_map = Map::AsElementsKind(initial_map, to_kind); |
mvstanton
2014/04/22 09:15:10
There isn't a way for Map::AsElementsKind to retur
| |
14848 RETURN_IF_EMPTY_HANDLE(isolate, initial_map); | |
14849 } | 14853 } |
14850 | 14854 |
14851 // If we don't care to track arrays of to_kind ElementsKind, then | 14855 // If we don't care to track arrays of to_kind ElementsKind, then |
14852 // don't emit a memento for them. | 14856 // don't emit a memento for them. |
14853 Handle<AllocationSite> allocation_site; | 14857 Handle<AllocationSite> allocation_site; |
14854 if (AllocationSite::GetMode(to_kind) == TRACK_ALLOCATION_SITE) { | 14858 if (AllocationSite::GetMode(to_kind) == TRACK_ALLOCATION_SITE) { |
14855 allocation_site = site; | 14859 allocation_site = site; |
14856 } | 14860 } |
14857 | 14861 |
14858 array = Handle<JSArray>::cast(factory->NewJSObjectFromMap( | 14862 array = Handle<JSArray>::cast(factory->NewJSObjectFromMap( |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
15042 } | 15046 } |
15043 } | 15047 } |
15044 | 15048 |
15045 | 15049 |
15046 void Runtime::OutOfMemory() { | 15050 void Runtime::OutOfMemory() { |
15047 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); | 15051 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); |
15048 UNREACHABLE(); | 15052 UNREACHABLE(); |
15049 } | 15053 } |
15050 | 15054 |
15051 } } // namespace v8::internal | 15055 } } // namespace v8::internal |
OLD | NEW |