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 5042 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5053 // Test that the number-string cache has not been resized in the snapshot. | 5053 // Test that the number-string cache has not been resized in the snapshot. |
5054 CcTest::InitializeVM(); | 5054 CcTest::InitializeVM(); |
5055 Isolate* isolate = CcTest::i_isolate(); | 5055 Isolate* isolate = CcTest::i_isolate(); |
5056 if (!isolate->snapshot_available()) return; | 5056 if (!isolate->snapshot_available()) return; |
5057 Heap* heap = isolate->heap(); | 5057 Heap* heap = isolate->heap(); |
5058 CHECK_EQ(TestHeap::kInitialNumberStringCacheSize * 2, | 5058 CHECK_EQ(TestHeap::kInitialNumberStringCacheSize * 2, |
5059 heap->number_string_cache()->length()); | 5059 heap->number_string_cache()->length()); |
5060 } | 5060 } |
5061 | 5061 |
5062 | 5062 |
| 5063 TEST(Regress3877) { |
| 5064 CcTest::InitializeVM(); |
| 5065 Isolate* isolate = CcTest::i_isolate(); |
| 5066 Heap* heap = isolate->heap(); |
| 5067 Factory* factory = isolate->factory(); |
| 5068 HandleScope scope(isolate); |
| 5069 CompileRun("function cls() { this.x = 10; }"); |
| 5070 Handle<WeakCell> weak_prototype; |
| 5071 { |
| 5072 HandleScope inner_scope(isolate); |
| 5073 v8::Local<v8::Value> result = CompileRun("cls.prototype"); |
| 5074 Handle<JSObject> proto = |
| 5075 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(result)); |
| 5076 weak_prototype = inner_scope.CloseAndEscape(factory->NewWeakCell(proto)); |
| 5077 } |
| 5078 CHECK(!weak_prototype->cleared()); |
| 5079 CompileRun( |
| 5080 "var a = { };" |
| 5081 "a.x = new cls();" |
| 5082 "cls.prototype = null;"); |
| 5083 for (int i = 0; i < 4; i++) { |
| 5084 heap->CollectAllGarbage(Heap::kNoGCFlags); |
| 5085 } |
| 5086 // The map of a.x keeps prototype alive |
| 5087 CHECK(!weak_prototype->cleared()); |
| 5088 // Change the map of a.x and make the previous map garbage collectable. |
| 5089 CompileRun("a.x.__proto__ = {};"); |
| 5090 for (int i = 0; i < 4; i++) { |
| 5091 heap->CollectAllGarbage(Heap::kNoGCFlags); |
| 5092 } |
| 5093 CHECK(weak_prototype->cleared()); |
| 5094 } |
| 5095 |
| 5096 |
5063 void CheckMapRetainingFor(int n) { | 5097 void CheckMapRetainingFor(int n) { |
5064 FLAG_retain_maps_for_n_gc = n; | 5098 FLAG_retain_maps_for_n_gc = n; |
5065 Isolate* isolate = CcTest::i_isolate(); | 5099 Isolate* isolate = CcTest::i_isolate(); |
5066 Heap* heap = isolate->heap(); | 5100 Heap* heap = isolate->heap(); |
5067 Handle<WeakCell> weak_cell; | 5101 Handle<WeakCell> weak_cell; |
5068 { | 5102 { |
5069 HandleScope inner_scope(isolate); | 5103 HandleScope inner_scope(isolate); |
5070 Handle<Map> map = Map::Create(isolate, 1); | 5104 Handle<Map> map = Map::Create(isolate, 1); |
5071 v8::Local<v8::Value> result = | 5105 v8::Local<v8::Value> result = |
5072 CompileRun("(function () { return {x : 10}; })();"); | 5106 CompileRun("(function () { return {x : 10}; })();"); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5110 | 5144 |
5111 TEST(WritableVsImmortalRoots) { | 5145 TEST(WritableVsImmortalRoots) { |
5112 for (int i = 0; i < Heap::kStrongRootListLength; ++i) { | 5146 for (int i = 0; i < Heap::kStrongRootListLength; ++i) { |
5113 Heap::RootListIndex root_index = static_cast<Heap::RootListIndex>(i); | 5147 Heap::RootListIndex root_index = static_cast<Heap::RootListIndex>(i); |
5114 bool writable = Heap::RootCanBeWrittenAfterInitialization(root_index); | 5148 bool writable = Heap::RootCanBeWrittenAfterInitialization(root_index); |
5115 bool immortal = Heap::RootIsImmortalImmovable(root_index); | 5149 bool immortal = Heap::RootIsImmortalImmovable(root_index); |
5116 // A root value can be writable, immortal, or neither, but not both. | 5150 // A root value can be writable, immortal, or neither, but not both. |
5117 CHECK(!immortal || !writable); | 5151 CHECK(!immortal || !writable); |
5118 } | 5152 } |
5119 } | 5153 } |
OLD | NEW |