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

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

Issue 183683022: Enable Object.observe by default (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: add back use strict 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
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());
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 1641 matching lines...) Expand 10 before | Expand all | Expand 10 after
3687 code = scope.CloseAndEscape(Handle<Code>(bar->code())); 3690 code = scope.CloseAndEscape(Handle<Code>(bar->code()));
3688 } 3691 }
3689 3692
3690 // Now make sure that a gc should get rid of the function 3693 // Now make sure that a gc should get rid of the function
3691 for (int i = 0; i < 4; i++) { 3694 for (int i = 0; i < 4; i++) {
3692 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); 3695 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
3693 } 3696 }
3694 3697
3695 ASSERT(code->marked_for_deoptimization()); 3698 ASSERT(code->marked_for_deoptimization());
3696 } 3699 }
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