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 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 if (*boilerplate == isolate->heap()->undefined_value()) { | 492 if (*boilerplate == isolate->heap()->undefined_value()) { |
493 boilerplate = CreateObjectLiteralBoilerplate(isolate, | 493 boilerplate = CreateObjectLiteralBoilerplate(isolate, |
494 literals, | 494 literals, |
495 constant_properties, | 495 constant_properties, |
496 should_have_fast_elements, | 496 should_have_fast_elements, |
497 has_function_literal); | 497 has_function_literal); |
498 RETURN_IF_EMPTY_HANDLE(isolate, boilerplate); | 498 RETURN_IF_EMPTY_HANDLE(isolate, boilerplate); |
499 // Update the functions literal and return the boilerplate. | 499 // Update the functions literal and return the boilerplate. |
500 literals->set(literals_index, *boilerplate); | 500 literals->set(literals_index, *boilerplate); |
501 } | 501 } |
502 | 502 return JSObject::cast(*boilerplate)->DeepCopy(isolate); |
503 Handle<Object> copy = JSObject::DeepCopy(Handle<JSObject>::cast(boilerplate)); | |
504 RETURN_IF_EMPTY_HANDLE(isolate, copy); | |
505 return *copy; | |
506 } | 503 } |
507 | 504 |
508 | 505 |
509 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateObjectLiteralShallow) { | 506 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateObjectLiteralShallow) { |
510 HandleScope scope(isolate); | 507 HandleScope scope(isolate); |
511 ASSERT(args.length() == 4); | 508 ASSERT(args.length() == 4); |
512 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); | 509 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); |
513 CONVERT_SMI_ARG_CHECKED(literals_index, 1); | 510 CONVERT_SMI_ARG_CHECKED(literals_index, 1); |
514 CONVERT_ARG_HANDLE_CHECKED(FixedArray, constant_properties, 2); | 511 CONVERT_ARG_HANDLE_CHECKED(FixedArray, constant_properties, 2); |
515 CONVERT_SMI_ARG_CHECKED(flags, 3); | 512 CONVERT_SMI_ARG_CHECKED(flags, 3); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 HandleScope scope(isolate); | 557 HandleScope scope(isolate); |
561 ASSERT(args.length() == 3); | 558 ASSERT(args.length() == 3); |
562 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); | 559 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); |
563 CONVERT_SMI_ARG_CHECKED(literals_index, 1); | 560 CONVERT_SMI_ARG_CHECKED(literals_index, 1); |
564 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2); | 561 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2); |
565 | 562 |
566 Handle<AllocationSite> site = GetLiteralAllocationSite(isolate, literals, | 563 Handle<AllocationSite> site = GetLiteralAllocationSite(isolate, literals, |
567 literals_index, elements); | 564 literals_index, elements); |
568 RETURN_IF_EMPTY_HANDLE(isolate, site); | 565 RETURN_IF_EMPTY_HANDLE(isolate, site); |
569 | 566 |
570 Handle<JSObject> boilerplate(JSObject::cast(site->transition_info())); | 567 JSObject* boilerplate = JSObject::cast(site->transition_info()); |
571 Handle<JSObject> copy = JSObject::DeepCopy(boilerplate); | 568 return boilerplate->DeepCopy(isolate); |
572 RETURN_IF_EMPTY_HANDLE(isolate, copy); | |
573 return *copy; | |
574 } | 569 } |
575 | 570 |
576 | 571 |
577 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteralShallow) { | 572 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteralShallow) { |
578 HandleScope scope(isolate); | 573 HandleScope scope(isolate); |
579 ASSERT(args.length() == 3); | 574 ASSERT(args.length() == 3); |
580 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); | 575 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); |
581 CONVERT_SMI_ARG_CHECKED(literals_index, 1); | 576 CONVERT_SMI_ARG_CHECKED(literals_index, 1); |
582 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2); | 577 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2); |
583 | 578 |
(...skipping 14200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14784 } | 14779 } |
14785 return NULL; | 14780 return NULL; |
14786 } | 14781 } |
14787 | 14782 |
14788 | 14783 |
14789 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { | 14784 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { |
14790 return &(kIntrinsicFunctions[static_cast<int>(id)]); | 14785 return &(kIntrinsicFunctions[static_cast<int>(id)]); |
14791 } | 14786 } |
14792 | 14787 |
14793 | 14788 |
14794 void Runtime::PerformGC(Object* result, Isolate* isolate) { | 14789 void Runtime::PerformGC(Object* result) { |
| 14790 Isolate* isolate = Isolate::Current(); |
14795 Failure* failure = Failure::cast(result); | 14791 Failure* failure = Failure::cast(result); |
14796 if (failure->IsRetryAfterGC()) { | 14792 if (failure->IsRetryAfterGC()) { |
14797 if (isolate->heap()->new_space()->AddFreshPage()) { | 14793 if (isolate->heap()->new_space()->AddFreshPage()) { |
14798 return; | 14794 return; |
14799 } | 14795 } |
14800 | 14796 |
14801 // Try to do a garbage collection; ignore it if it fails. The C | 14797 // Try to do a garbage collection; ignore it if it fails. The C |
14802 // entry stub will throw an out-of-memory exception in that case. | 14798 // entry stub will throw an out-of-memory exception in that case. |
14803 isolate->heap()->CollectGarbage(failure->allocation_space(), | 14799 isolate->heap()->CollectGarbage(failure->allocation_space(), |
14804 "Runtime::PerformGC"); | 14800 "Runtime::PerformGC"); |
14805 } else { | 14801 } else { |
14806 // Handle last resort GC and make sure to allow future allocations | 14802 // Handle last resort GC and make sure to allow future allocations |
14807 // to grow the heap without causing GCs (if possible). | 14803 // to grow the heap without causing GCs (if possible). |
14808 isolate->counters()->gc_last_resort_from_js()->Increment(); | 14804 isolate->counters()->gc_last_resort_from_js()->Increment(); |
14809 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 14805 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
14810 "Runtime::PerformGC"); | 14806 "Runtime::PerformGC"); |
14811 } | 14807 } |
14812 } | 14808 } |
14813 | 14809 |
14814 | 14810 |
14815 } } // namespace v8::internal | 14811 } } // namespace v8::internal |
OLD | NEW |