Remove script collected debug event.

R=yurys@chromium.org

Review URL: https://codereview.chromium.org/358873005

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22063 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
yangguo@chromium.org 2014-06-27 12:10:43 +00:00
parent f4ede82c98
commit 0133d96be3
10 changed files with 8 additions and 267 deletions

View File

@ -19,9 +19,8 @@ enum DebugEvent {
NewFunction = 3,
BeforeCompile = 4,
AfterCompile = 5,
ScriptCollected = 6,
CompileError = 7,
BreakForCommand = 8
CompileError = 6,
BreakForCommand = 7
};

View File

@ -454,6 +454,7 @@ OptimizedCompileJob::Status OptimizedCompileJob::GenerateCode() {
ASSERT(last_status() == SUCCEEDED);
ASSERT(!info()->HasAbortedDueToDependencyChange());
DisallowCodeDependencyChange no_dependency_change;
DisallowJavascriptExecution no_js(isolate());
{ // Scope for timer.
Timer timer(this, &time_taken_to_codegen_);
ASSERT(chunk_ != NULL);

View File

@ -208,10 +208,6 @@ function DebugEventDetails(response) {
details.text = result;
break;
case 'scriptCollected':
details.text = result;
break;
default:
details.text = 'Unknown debug event ' + response.event();
}

View File

@ -19,8 +19,7 @@ Debug.DebugEvent = { Break: 1,
NewFunction: 3,
BeforeCompile: 4,
AfterCompile: 5,
ScriptCollected: 6,
CompileError: 7 };
CompileError: 6 };
// Types of exceptions that can be broken upon.
Debug.ExceptionBreak = { Caught : 0,
@ -1183,31 +1182,6 @@ CompileEvent.prototype.toJSONProtocol = function() {
};
function MakeScriptCollectedEvent(id) {
return new ScriptCollectedEvent(id);
}
function ScriptCollectedEvent(id) {
this.id_ = id;
}
ScriptCollectedEvent.prototype.id = function() {
return this.id_;
};
ScriptCollectedEvent.prototype.toJSONProtocol = function() {
var o = new ProtocolMessage();
o.running = true;
o.event = "scriptCollected";
o.body = {};
o.body.script = { id: this.id() };
return o.toJSONProtocol();
};
function MakeScriptObject_(script, include_source) {
var o = { id: script.id(),
name: script.name(),

View File

@ -592,8 +592,7 @@ int Debug::ArchiveSpacePerThread() {
ScriptCache::ScriptCache(Isolate* isolate) : HashMap(HashMap::PointersMatch),
isolate_(isolate),
collected_scripts_(10) {
isolate_(isolate) {
Heap* heap = isolate_->heap();
HandleScope scope(isolate_);
@ -651,15 +650,6 @@ Handle<FixedArray> ScriptCache::GetScripts() {
}
void ScriptCache::ProcessCollectedScripts() {
Debug* debug = isolate_->debug();
for (int i = 0; i < collected_scripts_.length(); i++) {
debug->OnScriptCollected(collected_scripts_[i]);
}
collected_scripts_.Clear();
}
void ScriptCache::Clear() {
// Iterate the script cache to get rid of all the weak handles.
for (HashMap::Entry* entry = Start(); entry != NULL; entry = Next(entry)) {
@ -688,7 +678,6 @@ void ScriptCache::HandleWeakScript(
HashMap::Entry* entry = script_cache->Lookup(key, hash, false);
Object** location = reinterpret_cast<Object**>(entry->value);
script_cache->Remove(key, hash);
script_cache->collected_scripts_.Add(id);
// Clear the weak handle.
GlobalHandles::Destroy(location);
@ -2500,14 +2489,6 @@ void Debug::RecordEvalCaller(Handle<Script> script) {
}
void Debug::AfterGarbageCollection() {
// Generate events for collected scripts.
if (script_cache_ != NULL) {
script_cache_->ProcessCollectedScripts();
}
}
MaybeHandle<Object> Debug::MakeJSObject(const char* constructor_name,
int argc,
Handle<Object> argv[]) {
@ -2563,14 +2544,6 @@ MaybeHandle<Object> Debug::MakeCompileEvent(Handle<Script> script,
}
MaybeHandle<Object> Debug::MakeScriptCollectedEvent(int id) {
// Create the script collected event object.
Handle<Object> id_object = Handle<Smi>(Smi::FromInt(id), isolate_);
Handle<Object> argv[] = { id_object };
return MakeJSObject("MakeScriptCollectedEvent", ARRAY_SIZE(argv), argv);
}
void Debug::OnException(Handle<Object> exception, bool uncaught) {
if (in_debug_scope() || ignore_events()) return;
@ -2716,25 +2689,6 @@ void Debug::OnAfterCompile(Handle<Script> script) {
}
void Debug::OnScriptCollected(int id) {
if (in_debug_scope() || ignore_events()) return;
HandleScope scope(isolate_);
DebugScope debug_scope(this);
if (debug_scope.failed()) return;
// Create the script collected state object.
Handle<Object> event_data;
// Bail out and don't call debugger if exception.
if (!MakeScriptCollectedEvent(id).ToHandle(&event_data)) return;
// Process debug event.
ProcessDebugEvent(v8::ScriptCollected,
Handle<JSObject>::cast(event_data),
true);
}
void Debug::ProcessDebugEvent(v8::DebugEvent event,
Handle<JSObject> event_data,
bool auto_continue) {
@ -2836,9 +2790,6 @@ void Debug::NotifyMessageHandler(v8::DebugEvent event,
case v8::AfterCompile:
sendEventMessage = true;
break;
case v8::ScriptCollected:
sendEventMessage = true;
break;
case v8::NewFunction:
break;
default:
@ -2866,9 +2817,7 @@ void Debug::NotifyMessageHandler(v8::DebugEvent event,
// in the queue if any. For script collected events don't even process
// messages in the queue as the execution state might not be what is expected
// by the client.
if ((auto_continue && !has_commands()) || event == v8::ScriptCollected) {
return;
}
if (auto_continue && !has_commands()) return;
// DebugCommandProcessor goes here.
bool running = auto_continue;
@ -3251,7 +3200,7 @@ v8::Handle<v8::Context> MessageImpl::GetEventContext() const {
Isolate* isolate = event_data_->GetIsolate();
v8::Handle<v8::Context> context = GetDebugEventContext(isolate);
// Isolate::context() may be NULL when "script collected" event occures.
ASSERT(!context.IsEmpty() || event_ == v8::ScriptCollected);
ASSERT(!context.IsEmpty());
return context;
}

View File

@ -159,9 +159,6 @@ class ScriptCache : private HashMap {
// Return the scripts in the cache.
Handle<FixedArray> GetScripts();
// Generate debugger events for collected scripts.
void ProcessCollectedScripts();
private:
// Calculate the hash value from the key (script id).
static uint32_t Hash(int key) {
@ -176,8 +173,6 @@ class ScriptCache : private HashMap {
const v8::WeakCallbackData<v8::Value, void>& data);
Isolate* isolate_;
// List used during GC to temporarily store id's of collected scripts.
List<int> collected_scripts_;
};
@ -370,7 +365,6 @@ class Debug {
void OnCompileError(Handle<Script> script);
void OnBeforeCompile(Handle<Script> script);
void OnAfterCompile(Handle<Script> script);
void OnScriptCollected(int id);
// API facing.
void SetEventListener(Handle<Object> callback, Handle<Object> data);
@ -477,9 +471,6 @@ class Debug {
// Record function from which eval was called.
static void RecordEvalCaller(Handle<Script> script);
// Garbage collection notifications.
void AfterGarbageCollection();
// Flags and states.
DebugScope* debugger_entry() { return thread_local_.current_debug_scope_; }
inline Handle<Context> debug_context() { return debug_context_; }
@ -544,7 +535,6 @@ class Debug {
Handle<Object> promise);
MUST_USE_RESULT MaybeHandle<Object> MakeCompileEvent(
Handle<Script> script, v8::DebugEvent type);
MUST_USE_RESULT MaybeHandle<Object> MakeScriptCollectedEvent(int id);
// Mirror cache handling.
void ClearMirrorCache();

View File

@ -717,7 +717,6 @@ void Heap::GarbageCollectionEpilogue() {
#ifdef DEBUG
ReportStatisticsAfterGC();
#endif // DEBUG
isolate_->debug()->AfterGarbageCollection();
// Remember the last top pointer so that we can later find out
// whether we allocated in new space since the last GC.

View File

@ -6221,120 +6221,6 @@ TEST(NestedBreakEventContextData) {
}
// Debug event listener which counts the script collected events.
int script_collected_count = 0;
static void DebugEventScriptCollectedEvent(
const v8::Debug::EventDetails& event_details) {
v8::DebugEvent event = event_details.GetEvent();
// Count the number of breaks.
if (event == v8::ScriptCollected) {
script_collected_count++;
}
}
// Test that scripts collected are reported through the debug event listener.
TEST(ScriptCollectedEvent) {
v8::internal::Debug* debug = CcTest::i_isolate()->debug();
break_point_hit_count = 0;
script_collected_count = 0;
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
// Request the loaded scripts to initialize the debugger script cache.
debug->GetLoadedScripts();
// Do garbage collection to ensure that only the script in this test will be
// collected afterwards.
CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
script_collected_count = 0;
v8::Debug::SetDebugEventListener(DebugEventScriptCollectedEvent);
{
v8::Script::Compile(
v8::String::NewFromUtf8(env->GetIsolate(), "eval('a=1')"))->Run();
v8::Script::Compile(
v8::String::NewFromUtf8(env->GetIsolate(), "eval('a=2')"))->Run();
}
// Do garbage collection to collect the script above which is no longer
// referenced.
CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
CHECK_EQ(2, script_collected_count);
v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
// Debug event listener which counts the script collected events.
int script_collected_message_count = 0;
static void ScriptCollectedMessageHandler(const v8::Debug::Message& message) {
// Count the number of scripts collected.
if (message.IsEvent() && message.GetEvent() == v8::ScriptCollected) {
script_collected_message_count++;
v8::Handle<v8::Context> context = message.GetEventContext();
CHECK(context.IsEmpty());
}
}
// Test that GetEventContext doesn't fail and return empty handle for
// ScriptCollected events.
TEST(ScriptCollectedEventContext) {
i::FLAG_stress_compaction = false;
v8::Isolate* isolate = CcTest::isolate();
v8::internal::Debug* debug =
reinterpret_cast<v8::internal::Isolate*>(isolate)->debug();
script_collected_message_count = 0;
v8::HandleScope scope(isolate);
v8::Persistent<v8::Context> context;
{
v8::HandleScope scope(isolate);
context.Reset(isolate, v8::Context::New(isolate));
}
// Enter context. We can't have a handle to the context in the outer
// scope, so we have to do it the hard way.
{
v8::HandleScope scope(isolate);
v8::Local<v8::Context> local_context =
v8::Local<v8::Context>::New(isolate, context);
local_context->Enter();
}
// Request the loaded scripts to initialize the debugger script cache.
debug->GetLoadedScripts();
// Do garbage collection to ensure that only the script in this test will be
// collected afterwards.
CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
v8::Debug::SetMessageHandler(ScriptCollectedMessageHandler);
v8::Script::Compile(v8::String::NewFromUtf8(isolate, "eval('a=1')"))->Run();
v8::Script::Compile(v8::String::NewFromUtf8(isolate, "eval('a=2')"))->Run();
// Leave context
{
v8::HandleScope scope(isolate);
v8::Local<v8::Context> local_context =
v8::Local<v8::Context>::New(isolate, context);
local_context->Exit();
}
context.Reset();
// Do garbage collection to collect the script above which is no longer
// referenced.
CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
CHECK_EQ(2, script_collected_message_count);
v8::Debug::SetMessageHandler(NULL);
}
// Debug event listener which counts the after compile events.
int after_compile_message_count = 0;
static void AfterCompileMessageHandler(const v8::Debug::Message& message) {

View File

@ -1,53 +0,0 @@
// Copyright 2012 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 --expose-gc
// Check that we can cope with a debug listener that runs in the
// GC epilogue and causes enough allocation to trigger a new GC during
// the epilogue.
var f = eval("(function f() { return 42; })");
Debug = debug.Debug;
var called = false;
function listener(event, exec_state, event_data, data) {
if (event == Debug.DebugEvent.ScriptCollected) {
if (!called) {
called = true;
gc();
}
}
};
Debug.scripts();
Debug.setListener(listener);
f = void 0;
gc();
assertTrue(called);

View File

@ -51,7 +51,7 @@ EXPECTED_FUNCTION_COUNT = 415
EXPECTED_FUZZABLE_COUNT = 330
EXPECTED_CCTEST_COUNT = 6
EXPECTED_UNKNOWN_COUNT = 4
EXPECTED_BUILTINS_COUNT = 808
EXPECTED_BUILTINS_COUNT = 806
# Don't call these at all.