Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: test/cctest/test-heap.cc

Issue 190853007: Revert "Enable Object.observe by default" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/runtime.cc ('k') | test/cctest/test-microtask-delivery.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 = {};");
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
2014 CompileRun( 2007 CompileRun(
2008 "var base = {};"
2015 "var live = [];" 2009 "var live = [];"
2016 "for (var i = 0; i < 10; i++) {" 2010 "for (var i = 0; i < 10; i++) {"
2017 " var object = {};" 2011 " var object = {};"
2018 " var prototype = {};" 2012 " var prototype = {};"
2019 " object.__proto__ = prototype;" 2013 " object.__proto__ = prototype;"
2020 " if (i >= 3) live.push(object, prototype);" 2014 " if (i >= 3) live.push(object, prototype);"
2021 "}"); 2015 "}");
2022 2016
2017 Handle<JSObject> baseObject =
2018 v8::Utils::OpenHandle(
2019 *v8::Handle<v8::Object>::Cast(
2020 CcTest::global()->Get(v8_str("base"))));
2021
2023 // Verify that only dead prototype transitions are cleared. 2022 // Verify that only dead prototype transitions are cleared.
2024 CHECK_EQ(initialTransitions + 10, 2023 CHECK_EQ(10, baseObject->map()->NumberOfProtoTransitions());
2025 baseObject->map()->NumberOfProtoTransitions());
2026 CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); 2024 CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
2027 const int transitions = 10 - 3; 2025 const int transitions = 10 - 3;
2028 CHECK_EQ(initialTransitions + transitions, 2026 CHECK_EQ(transitions, baseObject->map()->NumberOfProtoTransitions());
2029 baseObject->map()->NumberOfProtoTransitions());
2030 2027
2031 // Verify that prototype transitions array was compacted. 2028 // Verify that prototype transitions array was compacted.
2032 FixedArray* trans = baseObject->map()->GetPrototypeTransitions(); 2029 FixedArray* trans = baseObject->map()->GetPrototypeTransitions();
2033 for (int i = initialTransitions; i < initialTransitions + transitions; i++) { 2030 for (int i = 0; i < transitions; i++) {
2034 int j = Map::kProtoTransitionHeaderSize + 2031 int j = Map::kProtoTransitionHeaderSize +
2035 i * Map::kProtoTransitionElementsPerEntry; 2032 i * Map::kProtoTransitionElementsPerEntry;
2036 CHECK(trans->get(j + Map::kProtoTransitionMapOffset)->IsMap()); 2033 CHECK(trans->get(j + Map::kProtoTransitionMapOffset)->IsMap());
2037 Object* proto = trans->get(j + Map::kProtoTransitionPrototypeOffset); 2034 Object* proto = trans->get(j + Map::kProtoTransitionPrototypeOffset);
2038 CHECK(proto->IsJSObject()); 2035 CHECK(proto->IsTheHole() || proto->IsJSObject());
2039 } 2036 }
2040 2037
2041 // Make sure next prototype is placed on an old-space evacuation candidate. 2038 // Make sure next prototype is placed on an old-space evacuation candidate.
2042 Handle<JSObject> prototype; 2039 Handle<JSObject> prototype;
2043 PagedSpace* space = CcTest::heap()->old_pointer_space(); 2040 PagedSpace* space = CcTest::heap()->old_pointer_space();
2044 { 2041 {
2045 AlwaysAllocateScope always_allocate; 2042 AlwaysAllocateScope always_allocate;
2046 SimulateFullSpace(space); 2043 SimulateFullSpace(space);
2047 prototype = factory->NewJSArray(32 * KB, FAST_HOLEY_ELEMENTS, TENURED); 2044 prototype = factory->NewJSArray(32 * KB, FAST_HOLEY_ELEMENTS, TENURED);
2048 } 2045 }
(...skipping 1641 matching lines...) Expand 10 before | Expand all | Expand 10 after
3690 code = scope.CloseAndEscape(Handle<Code>(bar->code())); 3687 code = scope.CloseAndEscape(Handle<Code>(bar->code()));
3691 } 3688 }
3692 3689
3693 // Now make sure that a gc should get rid of the function 3690 // Now make sure that a gc should get rid of the function
3694 for (int i = 0; i < 4; i++) { 3691 for (int i = 0; i < 4; i++) {
3695 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); 3692 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
3696 } 3693 }
3697 3694
3698 ASSERT(code->marked_for_deoptimization()); 3695 ASSERT(code->marked_for_deoptimization());
3699 } 3696 }
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | test/cctest/test-microtask-delivery.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698