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