OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 | 2 |
3 #include <stdlib.h> | 3 #include <stdlib.h> |
4 | 4 |
5 #include "v8.h" | 5 #include "v8.h" |
6 | 6 |
7 #include "compilation-cache.h" | 7 #include "compilation-cache.h" |
8 #include "execution.h" | 8 #include "execution.h" |
9 #include "factory.h" | 9 #include "factory.h" |
10 #include "macro-assembler.h" | 10 #include "macro-assembler.h" |
(...skipping 2676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2687 #ifdef DEBUG | 2687 #ifdef DEBUG |
2688 FLAG_stop_at = "f"; | 2688 FLAG_stop_at = "f"; |
2689 #endif | 2689 #endif |
2690 CompileRun("%OptimizeFunctionOnNextCall(g);" | 2690 CompileRun("%OptimizeFunctionOnNextCall(g);" |
2691 "g(false);"); | 2691 "g(false);"); |
2692 | 2692 |
2693 // Finish garbage collection cycle. | 2693 // Finish garbage collection cycle. |
2694 HEAP->CollectAllGarbage(Heap::kNoGCFlags); | 2694 HEAP->CollectAllGarbage(Heap::kNoGCFlags); |
2695 CHECK(shared1->code()->gc_metadata() == NULL); | 2695 CHECK(shared1->code()->gc_metadata() == NULL); |
2696 } | 2696 } |
2697 | |
2698 | |
2699 // Helper function that simulates a fill new-space in the heap. | |
2700 static inline void AllocateAllButNBytes(v8::internal::NewSpace* space, | |
2701 int extra_bytes) { | |
2702 int space_remaining = static_cast<int>( | |
2703 *space->allocation_limit_address() - *space->allocation_top_address()); | |
2704 CHECK(space_remaining >= extra_bytes); | |
2705 int new_linear_size = space_remaining - extra_bytes; | |
2706 v8::internal::MaybeObject* maybe = space->AllocateRaw(new_linear_size); | |
2707 v8::internal::FreeListNode* node = v8::internal::FreeListNode::cast(maybe); | |
2708 node->set_size(space->heap(), new_linear_size); | |
2709 } | |
2710 | |
2711 | |
2712 TEST(Regress169928) { | |
2713 i::FLAG_allow_natives_syntax = true; | |
2714 i::FLAG_crankshaft = false; | |
2715 InitializeVM(); | |
2716 v8::HandleScope scope; | |
2717 | |
2718 // Some flags turn Scavenge collections into Mark-sweep collections | |
2719 // and hence are incompatible with this test case. | |
2720 if (FLAG_gc_global || FLAG_stress_compaction) return; | |
2721 | |
2722 // Prepare the environment | |
2723 CompileRun("function fastliteralcase(literal, value) {" | |
2724 " literal[0] = value;" | |
2725 " return literal;" | |
2726 "}" | |
2727 "function get_standard_literal() {" | |
2728 " var literal = [1, 2, 3];" | |
2729 " return literal;" | |
2730 "}" | |
2731 "obj = fastliteralcase(get_standard_literal(), 1);" | |
2732 "obj = fastliteralcase(get_standard_literal(), 1.5);" | |
2733 "obj = fastliteralcase(get_standard_literal(), 2);"); | |
2734 | |
2735 // prepare the heap | |
2736 v8::Local<v8::String> mote_code_string = | |
2737 v8_str("fastliteralcase(mote, 2.5);"); | |
2738 | |
2739 v8::Local<v8::String> array_name = v8_str("mote"); | |
2740 v8::Context::GetCurrent()->Global()->Set(array_name, v8::Int32::New(0)); | |
2741 | |
2742 // First make sure we flip spaces | |
2743 #ifdef DEBUG | |
2744 Address* limit_addr = HEAP->new_space()->allocation_limit_address(); | |
ulan_google
2013/01/21 12:21:07
Now that the assertion is removed, this code seems
mvstanton
2013/01/21 12:25:40
Oh indeed, thanks for catching that Ulan!
| |
2745 Address limit = *limit_addr; | |
2746 #endif | |
2747 HEAP->CollectGarbage(NEW_SPACE); | |
2748 | |
2749 // Allocate the object. | |
2750 Handle<FixedArray> array_data = FACTORY->NewFixedArray(2, NOT_TENURED); | |
2751 array_data->set(0, Smi::FromInt(1)); | |
2752 array_data->set(1, Smi::FromInt(2)); | |
2753 | |
2754 AllocateAllButNBytes(HEAP->new_space(), | |
2755 JSArray::kSize + AllocationSiteInfo::kSize + | |
2756 kPointerSize); | |
2757 | |
2758 Handle<JSArray> array = FACTORY->NewJSArrayWithElements(array_data, | |
2759 FAST_SMI_ELEMENTS, | |
2760 NOT_TENURED); | |
2761 | |
2762 CHECK_EQ(Smi::FromInt(2), array->length()); | |
2763 CHECK(array->HasFastSmiOrObjectElements()); | |
2764 | |
2765 // We need filler the size of AllocationSiteInfo object, plus an extra | |
2766 // fill pointer value. | |
2767 MaybeObject* maybe_object = HEAP->AllocateRaw( | |
2768 AllocationSiteInfo::kSize + kPointerSize, NEW_SPACE, OLD_POINTER_SPACE); | |
2769 Object* obj = NULL; | |
2770 CHECK(maybe_object->ToObject(&obj)); | |
2771 Address addr_obj = reinterpret_cast<Address>( | |
2772 reinterpret_cast<byte*>(obj - kHeapObjectTag)); | |
2773 HEAP->CreateFillerObjectAt(addr_obj, | |
2774 AllocationSiteInfo::kSize + kPointerSize); | |
2775 | |
2776 // Give the array a name, making sure not to allocate strings. | |
2777 v8::Handle<v8::Object> array_obj = v8::Utils::ToLocal(array); | |
2778 v8::Context::GetCurrent()->Global()->Set(array_name, array_obj); | |
2779 | |
2780 // This should crash with a protection violation if we are running a build | |
2781 // with the bug. | |
2782 AlwaysAllocateScope aa_scope; | |
2783 v8::Script::Compile(mote_code_string)->Run(); | |
2784 } | |
OLD | NEW |