Revision: 21644
Author: [email protected]
Date: Tue Jun 3 14:27:19 2014 UTC
Log: Add option to disable MirrorCache.
[email protected]
Review URL: https://codereview.chromium.org/307383002
http://code.google.com/p/v8/source/detail?r=21644
Added:
/branches/bleeding_edge/test/mjsunit/debug-toggle-mirror-cache.js
Modified:
/branches/bleeding_edge/src/debug.cc
/branches/bleeding_edge/src/mirror-debugger.js
/branches/bleeding_edge/tools/generate-runtime-tests.py
=======================================
--- /dev/null
+++ /branches/bleeding_edge/test/mjsunit/debug-toggle-mirror-cache.js Tue
Jun 3 14:27:19 2014 UTC
@@ -0,0 +1,40 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Flags: --expose-debug-as debug
+
+var handle1 = debug.MakeMirror(123).handle();
+assertEquals("number", debug.LookupMirror(handle1).type());
+
+debug.ToggleMirrorCache(false);
+var handle2 = debug.MakeMirror(123).handle();
+assertEquals(undefined, handle2);
+assertThrows(function() { debug.LookupMirror(handle2) });
+
+debug.ToggleMirrorCache(true);
+var handle3 = debug.MakeMirror(123).handle();
+assertEquals("number", debug.LookupMirror(handle3).type());
=======================================
--- /branches/bleeding_edge/src/debug.cc Tue Jun 3 08:12:43 2014 UTC
+++ /branches/bleeding_edge/src/debug.cc Tue Jun 3 14:27:19 2014 UTC
@@ -2459,17 +2459,17 @@
PostponeInterruptsScope postpone(isolate_);
HandleScope scope(isolate_);
ASSERT(isolate_->context() == *Debug::debug_context());
-
- // Clear the mirror cache.
- Handle<Object> fun = Object::GetProperty(
- isolate_,
- isolate_->global_object(),
- "ClearMirrorCache").ToHandleChecked();
- ASSERT(fun->IsJSFunction());
- Execution::TryCall(Handle<JSFunction>::cast(fun),
-
Handle<JSObject>(Debug::debug_context()->global_object()),
- 0,
- NULL);
+ Factory* factory = isolate_->factory();
+ JSObject::SetProperty(isolate_->global_object(),
+ factory->NewStringFromAsciiChecked("next_handle_"),
+ handle(Smi::FromInt(0), isolate_),
+ NONE,
+ SLOPPY).Check();
+ JSObject::SetProperty(isolate_->global_object(),
+ factory->NewStringFromAsciiChecked("mirror_cache_"),
+ factory->NewJSArray(0, FAST_ELEMENTS),
+ NONE,
+ SLOPPY).Check();
}
=======================================
--- /branches/bleeding_edge/src/mirror-debugger.js Thu May 22 15:27:57 2014
UTC
+++ /branches/bleeding_edge/src/mirror-debugger.js Tue Jun 3 14:27:19 2014
UTC
@@ -8,6 +8,14 @@
// Mirror cache.
var mirror_cache_ = [];
+var mirror_cache_enabled_ = true;
+
+
+function ToggleMirrorCache(value) {
+ mirror_cache_enabled_ = value;
+ next_handle_ = 0;
+ mirror_cache_ = [];
+}
/**
@@ -44,7 +52,7 @@
var mirror;
// Look for non transient mirrors in the mirror cache.
- if (!opt_transient) {
+ if (!opt_transient && mirror_cache_enabled_) {
for (id in mirror_cache_) {
mirror = mirror_cache_[id];
if (mirror.value() === value) {
@@ -88,7 +96,7 @@
mirror = new ObjectMirror(value, OBJECT_TYPE, opt_transient);
}
- mirror_cache_[mirror.handle()] = mirror;
+ if (mirror_cache_enabled_) mirror_cache_[mirror.handle()] = mirror;
return mirror;
}
@@ -101,6 +109,7 @@
* undefined if no mirror with the requested handle was found
*/
function LookupMirror(handle) {
+ if (!mirror_cache_enabled_) throw new Error("Mirror cache is disabled");
return mirror_cache_[handle];
}
@@ -424,7 +433,7 @@
* Allocate a handle id for this object.
*/
Mirror.prototype.allocateHandle_ = function() {
- this.handle_ = next_handle_++;
+ if (mirror_cache_enabled_) this.handle_ = next_handle_++;
};
=======================================
--- /branches/bleeding_edge/tools/generate-runtime-tests.py Tue Jun 3
00:34:01 2014 UTC
+++ /branches/bleeding_edge/tools/generate-runtime-tests.py Tue Jun 3
14:27:19 2014 UTC
@@ -51,7 +51,7 @@
EXPECTED_FUZZABLE_COUNT = 325
EXPECTED_CCTEST_COUNT = 6
EXPECTED_UNKNOWN_COUNT = 5
-EXPECTED_BUILTINS_COUNT = 797
+EXPECTED_BUILTINS_COUNT = 798
# Don't call these at all.
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.