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 1986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1997 CcTest::heap()->CollectGarbage(OLD_POINTER_SPACE); | 1997 CcTest::heap()->CollectGarbage(OLD_POINTER_SPACE); |
1998 } | 1998 } |
1999 | 1999 |
2000 | 2000 |
2001 TEST(PrototypeTransitionClearing) { | 2001 TEST(PrototypeTransitionClearing) { |
2002 CcTest::InitializeVM(); | 2002 CcTest::InitializeVM(); |
2003 Isolate* isolate = CcTest::i_isolate(); | 2003 Isolate* isolate = CcTest::i_isolate(); |
2004 Factory* factory = isolate->factory(); | 2004 Factory* factory = isolate->factory(); |
2005 v8::HandleScope scope(CcTest::isolate()); | 2005 v8::HandleScope scope(CcTest::isolate()); |
2006 | 2006 |
2007 CompileRun("var base = {};"); | |
rafaelw
2014/03/05 00:48:46
Note: the way this test was structured was asserti
rossberg
2014/03/06 08:41:35
Sounds plausible, although you never know if there
Toon Verwaest
2014/03/06 13:01:25
Sounds good to me.
On 2014/03/06 08:41:35, rossbe
| |
2008 Handle<JSObject> baseObject = | |
2009 v8::Utils::OpenHandle( | |
2010 *v8::Handle<v8::Object>::Cast( | |
2011 CcTest::global()->Get(v8_str("base")))); | |
2012 int initialTransitions = baseObject->map()->NumberOfProtoTransitions(); | |
2013 | |
2007 CompileRun( | 2014 CompileRun( |
2008 "var base = {};" | |
2009 "var live = [];" | 2015 "var live = [];" |
2010 "for (var i = 0; i < 10; i++) {" | 2016 "for (var i = 0; i < 10; i++) {" |
2011 " var object = {};" | 2017 " var object = {};" |
2012 " var prototype = {};" | 2018 " var prototype = {};" |
2013 " object.__proto__ = prototype;" | 2019 " object.__proto__ = prototype;" |
2014 " if (i >= 3) live.push(object, prototype);" | 2020 " if (i >= 3) live.push(object, prototype);" |
2015 "}"); | 2021 "}"); |
2016 | 2022 |
2017 Handle<JSObject> baseObject = | |
2018 v8::Utils::OpenHandle( | |
2019 *v8::Handle<v8::Object>::Cast( | |
2020 CcTest::global()->Get(v8_str("base")))); | |
2021 | |
2022 // Verify that only dead prototype transitions are cleared. | 2023 // Verify that only dead prototype transitions are cleared. |
2023 CHECK_EQ(10, baseObject->map()->NumberOfProtoTransitions()); | 2024 CHECK_EQ(initialTransitions + 10, |
2025 baseObject->map()->NumberOfProtoTransitions()); | |
2024 CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 2026 CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
2025 const int transitions = 10 - 3; | 2027 const int transitions = 10 - 3; |
2026 CHECK_EQ(transitions, baseObject->map()->NumberOfProtoTransitions()); | 2028 CHECK_EQ(initialTransitions + transitions, |
2029 baseObject->map()->NumberOfProtoTransitions()); | |
2027 | 2030 |
2028 // Verify that prototype transitions array was compacted. | 2031 // Verify that prototype transitions array was compacted. |
2029 FixedArray* trans = baseObject->map()->GetPrototypeTransitions(); | 2032 FixedArray* trans = baseObject->map()->GetPrototypeTransitions(); |
2030 for (int i = 0; i < transitions; i++) { | 2033 for (int i = initialTransitions; i < initialTransitions + transitions; i++) { |
2031 int j = Map::kProtoTransitionHeaderSize + | 2034 int j = Map::kProtoTransitionHeaderSize + |
2032 i * Map::kProtoTransitionElementsPerEntry; | 2035 i * Map::kProtoTransitionElementsPerEntry; |
2033 CHECK(trans->get(j + Map::kProtoTransitionMapOffset)->IsMap()); | 2036 CHECK(trans->get(j + Map::kProtoTransitionMapOffset)->IsMap()); |
2034 Object* proto = trans->get(j + Map::kProtoTransitionPrototypeOffset); | 2037 Object* proto = trans->get(j + Map::kProtoTransitionPrototypeOffset); |
2035 CHECK(proto->IsTheHole() || proto->IsJSObject()); | 2038 CHECK(proto->IsJSObject()); |
rafaelw
2014/03/05 00:48:46
It seems like the check for the hole here was actu
| |
2036 } | 2039 } |
2037 | 2040 |
2038 // Make sure next prototype is placed on an old-space evacuation candidate. | 2041 // Make sure next prototype is placed on an old-space evacuation candidate. |
2039 Handle<JSObject> prototype; | 2042 Handle<JSObject> prototype; |
2040 PagedSpace* space = CcTest::heap()->old_pointer_space(); | 2043 PagedSpace* space = CcTest::heap()->old_pointer_space(); |
2041 { | 2044 { |
2042 AlwaysAllocateScope always_allocate; | 2045 AlwaysAllocateScope always_allocate; |
2043 SimulateFullSpace(space); | 2046 SimulateFullSpace(space); |
2044 prototype = factory->NewJSArray(32 * KB, FAST_HOLEY_ELEMENTS, TENURED); | 2047 prototype = factory->NewJSArray(32 * KB, FAST_HOLEY_ELEMENTS, TENURED); |
2045 } | 2048 } |
(...skipping 1640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3686 code = scope.CloseAndEscape(Handle<Code>(bar->code())); | 3689 code = scope.CloseAndEscape(Handle<Code>(bar->code())); |
3687 } | 3690 } |
3688 | 3691 |
3689 // Now make sure that a gc should get rid of the function | 3692 // Now make sure that a gc should get rid of the function |
3690 for (int i = 0; i < 4; i++) { | 3693 for (int i = 0; i < 4; i++) { |
3691 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 3694 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
3692 } | 3695 } |
3693 | 3696 |
3694 ASSERT(code->marked_for_deoptimization()); | 3697 ASSERT(code->marked_for_deoptimization()); |
3695 } | 3698 } |
OLD | NEW |