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 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 | 547 |
548 literals->set(literals_index, *site); | 548 literals->set(literals_index, *site); |
549 } else { | 549 } else { |
550 site = Handle<AllocationSite>::cast(literal_site); | 550 site = Handle<AllocationSite>::cast(literal_site); |
551 } | 551 } |
552 | 552 |
553 return site; | 553 return site; |
554 } | 554 } |
555 | 555 |
556 | 556 |
| 557 static MaybeObject* CreateArrayLiteralImpl(Isolate* isolate, |
| 558 Handle<FixedArray> literals, |
| 559 int literals_index, |
| 560 Handle<FixedArray> elements, |
| 561 int flags) { |
| 562 Handle<AllocationSite> site = GetLiteralAllocationSite(isolate, literals, |
| 563 literals_index, elements); |
| 564 RETURN_IF_EMPTY_HANDLE(isolate, site); |
| 565 |
| 566 bool enable_mementos = (flags & ArrayLiteral::kDisableMementos) == 0; |
| 567 Handle<JSObject> boilerplate(JSObject::cast(site->transition_info())); |
| 568 AllocationSiteUsageContext usage_context(isolate, site, enable_mementos); |
| 569 usage_context.EnterNewScope(); |
| 570 JSObject::DeepCopyHints hints = (flags & ArrayLiteral::kShallowElements) == 0 |
| 571 ? JSObject::kNoHints |
| 572 : JSObject::kObjectIsShallowArray; |
| 573 Handle<JSObject> copy = JSObject::DeepCopy(boilerplate, &usage_context, |
| 574 hints); |
| 575 usage_context.ExitScope(site, boilerplate); |
| 576 RETURN_IF_EMPTY_HANDLE(isolate, copy); |
| 577 return *copy; |
| 578 } |
| 579 |
| 580 |
557 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteral) { | 581 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteral) { |
558 HandleScope scope(isolate); | 582 HandleScope scope(isolate); |
| 583 ASSERT(args.length() == 4); |
| 584 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); |
| 585 CONVERT_SMI_ARG_CHECKED(literals_index, 1); |
| 586 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2); |
| 587 CONVERT_SMI_ARG_CHECKED(flags, 3); |
| 588 |
| 589 return CreateArrayLiteralImpl(isolate, literals, literals_index, elements, |
| 590 flags); |
| 591 } |
| 592 |
| 593 |
| 594 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteralStubBailout) { |
| 595 HandleScope scope(isolate); |
559 ASSERT(args.length() == 3); | 596 ASSERT(args.length() == 3); |
560 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); | 597 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); |
561 CONVERT_SMI_ARG_CHECKED(literals_index, 1); | 598 CONVERT_SMI_ARG_CHECKED(literals_index, 1); |
562 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2); | 599 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2); |
563 | 600 |
564 Handle<AllocationSite> site = GetLiteralAllocationSite(isolate, literals, | 601 return CreateArrayLiteralImpl(isolate, literals, literals_index, elements, |
565 literals_index, elements); | 602 ArrayLiteral::kShallowElements); |
566 RETURN_IF_EMPTY_HANDLE(isolate, site); | |
567 | |
568 Handle<JSObject> boilerplate(JSObject::cast(site->transition_info())); | |
569 AllocationSiteUsageContext usage_context(isolate, site, true); | |
570 usage_context.EnterNewScope(); | |
571 Handle<JSObject> copy = JSObject::DeepCopy(boilerplate, &usage_context); | |
572 usage_context.ExitScope(site, boilerplate); | |
573 RETURN_IF_EMPTY_HANDLE(isolate, copy); | |
574 return *copy; | |
575 } | 603 } |
576 | 604 |
577 | 605 |
578 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateSymbol) { | 606 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateSymbol) { |
579 HandleScope scope(isolate); | 607 HandleScope scope(isolate); |
580 ASSERT(args.length() == 1); | 608 ASSERT(args.length() == 1); |
581 Handle<Object> name(args[0], isolate); | 609 Handle<Object> name(args[0], isolate); |
582 RUNTIME_ASSERT(name->IsString() || name->IsUndefined()); | 610 RUNTIME_ASSERT(name->IsString() || name->IsUndefined()); |
583 Symbol* symbol; | 611 Symbol* symbol; |
584 MaybeObject* maybe = isolate->heap()->AllocateSymbol(); | 612 MaybeObject* maybe = isolate->heap()->AllocateSymbol(); |
(...skipping 14332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14917 // Handle last resort GC and make sure to allow future allocations | 14945 // Handle last resort GC and make sure to allow future allocations |
14918 // to grow the heap without causing GCs (if possible). | 14946 // to grow the heap without causing GCs (if possible). |
14919 isolate->counters()->gc_last_resort_from_js()->Increment(); | 14947 isolate->counters()->gc_last_resort_from_js()->Increment(); |
14920 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 14948 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
14921 "Runtime::PerformGC"); | 14949 "Runtime::PerformGC"); |
14922 } | 14950 } |
14923 } | 14951 } |
14924 | 14952 |
14925 | 14953 |
14926 } } // namespace v8::internal | 14954 } } // namespace v8::internal |
OLD | NEW |