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

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

Issue 195123005: 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 1985 matching lines...) Expand 10 before | Expand all | Expand 10 after
1996 CcTest::heap()->CollectGarbage(OLD_POINTER_SPACE); 1996 CcTest::heap()->CollectGarbage(OLD_POINTER_SPACE);
1997 } 1997 }
1998 1998
1999 1999
2000 TEST(PrototypeTransitionClearing) { 2000 TEST(PrototypeTransitionClearing) {
2001 CcTest::InitializeVM(); 2001 CcTest::InitializeVM();
2002 Isolate* isolate = CcTest::i_isolate(); 2002 Isolate* isolate = CcTest::i_isolate();
2003 Factory* factory = isolate->factory(); 2003 Factory* factory = isolate->factory();
2004 v8::HandleScope scope(CcTest::isolate()); 2004 v8::HandleScope scope(CcTest::isolate());
2005 2005
2006 CompileRun("var base = {};");
2007 Handle<JSObject> baseObject =
2008 v8::Utils::OpenHandle(
2009 *v8::Handle<v8::Object>::Cast(
2010 CcTest::global()->Get(v8_str("base"))));
2011 int initialTransitions = baseObject->map()->NumberOfProtoTransitions();
2012
2013 CompileRun( 2006 CompileRun(
2007 "var base = {};"
2014 "var live = [];" 2008 "var live = [];"
2015 "for (var i = 0; i < 10; i++) {" 2009 "for (var i = 0; i < 10; i++) {"
2016 " var object = {};" 2010 " var object = {};"
2017 " var prototype = {};" 2011 " var prototype = {};"
2018 " object.__proto__ = prototype;" 2012 " object.__proto__ = prototype;"
2019 " if (i >= 3) live.push(object, prototype);" 2013 " if (i >= 3) live.push(object, prototype);"
2020 "}"); 2014 "}");
2021 2015
2016 Handle<JSObject> baseObject =
2017 v8::Utils::OpenHandle(
2018 *v8::Handle<v8::Object>::Cast(
2019 CcTest::global()->Get(v8_str("base"))));
2020
2022 // Verify that only dead prototype transitions are cleared. 2021 // Verify that only dead prototype transitions are cleared.
2023 CHECK_EQ(initialTransitions + 10, 2022 CHECK_EQ(10, baseObject->map()->NumberOfProtoTransitions());
2024 baseObject->map()->NumberOfProtoTransitions());
2025 CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); 2023 CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
2026 const int transitions = 10 - 3; 2024 const int transitions = 10 - 3;
2027 CHECK_EQ(initialTransitions + transitions, 2025 CHECK_EQ(transitions, baseObject->map()->NumberOfProtoTransitions());
2028 baseObject->map()->NumberOfProtoTransitions());
2029 2026
2030 // Verify that prototype transitions array was compacted. 2027 // Verify that prototype transitions array was compacted.
2031 FixedArray* trans = baseObject->map()->GetPrototypeTransitions(); 2028 FixedArray* trans = baseObject->map()->GetPrototypeTransitions();
2032 for (int i = initialTransitions; i < initialTransitions + transitions; i++) { 2029 for (int i = 0; i < transitions; i++) {
2033 int j = Map::kProtoTransitionHeaderSize + 2030 int j = Map::kProtoTransitionHeaderSize +
2034 i * Map::kProtoTransitionElementsPerEntry; 2031 i * Map::kProtoTransitionElementsPerEntry;
2035 CHECK(trans->get(j + Map::kProtoTransitionMapOffset)->IsMap()); 2032 CHECK(trans->get(j + Map::kProtoTransitionMapOffset)->IsMap());
2036 Object* proto = trans->get(j + Map::kProtoTransitionPrototypeOffset); 2033 Object* proto = trans->get(j + Map::kProtoTransitionPrototypeOffset);
2037 CHECK(proto->IsJSObject()); 2034 CHECK(proto->IsTheHole() || proto->IsJSObject());
2038 } 2035 }
2039 2036
2040 // Make sure next prototype is placed on an old-space evacuation candidate. 2037 // Make sure next prototype is placed on an old-space evacuation candidate.
2041 Handle<JSObject> prototype; 2038 Handle<JSObject> prototype;
2042 PagedSpace* space = CcTest::heap()->old_pointer_space(); 2039 PagedSpace* space = CcTest::heap()->old_pointer_space();
2043 { 2040 {
2044 AlwaysAllocateScope always_allocate; 2041 AlwaysAllocateScope always_allocate;
2045 SimulateFullSpace(space); 2042 SimulateFullSpace(space);
2046 prototype = factory->NewJSArray(32 * KB, FAST_HOLEY_ELEMENTS, TENURED); 2043 prototype = factory->NewJSArray(32 * KB, FAST_HOLEY_ELEMENTS, TENURED);
2047 } 2044 }
(...skipping 1685 matching lines...) Expand 10 before | Expand all | Expand 10 after
3733 v8::Handle<v8::Object> global = CcTest::global(); 3730 v8::Handle<v8::Object> global = CcTest::global();
3734 v8::Handle<v8::Function> g = 3731 v8::Handle<v8::Function> g =
3735 v8::Handle<v8::Function>::Cast(global->Get(v8_str("crash"))); 3732 v8::Handle<v8::Function>::Cast(global->Get(v8_str("crash")));
3736 v8::Handle<v8::Value> args1[] = { v8_num(1) }; 3733 v8::Handle<v8::Value> args1[] = { v8_num(1) };
3737 heap->DisableInlineAllocation(); 3734 heap->DisableInlineAllocation();
3738 heap->set_allocation_timeout(1); 3735 heap->set_allocation_timeout(1);
3739 g->Call(global, 1, args1); 3736 g->Call(global, 1, args1);
3740 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); 3737 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
3741 } 3738 }
3742 #endif 3739 #endif
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