Reviewers: mvstanton,

Description:
Do not use js builtins object to determine whether a function is a builtin.

We can use the script type to determine that instead. We already do that
to figure out whether a function is subject to debugging. We also use
IsBuiltin and IsSubjectToDebugging interchangeably. For debugger, we now
use the latter, hiding the detail that non-builtins are debuggable.

[email protected]

Please review this at https://codereview.chromium.org/1292283004/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+16, -11 lines):
  M src/debug/debug.cc
  M src/debug/debug-scopes.cc
  M src/objects.h
  M src/objects-inl.h
  M src/runtime/runtime-debug.cc


Index: src/debug/debug-scopes.cc
diff --git a/src/debug/debug-scopes.cc b/src/debug/debug-scopes.cc
index 62b78b472833e8fe996a00b771a4378f07716363..e21d92911f407eda75a3c1c7c7ec1e07ceb3aeea 100644
--- a/src/debug/debug-scopes.cc
+++ b/src/debug/debug-scopes.cc
@@ -118,7 +118,7 @@ ScopeIterator::ScopeIterator(Isolate* isolate, Handle<JSFunction> function)
       context_(function->context()),
       seen_script_scope_(false),
       failed_(false) {
-  if (function->IsBuiltin()) context_ = Handle<Context>();
+  if (!function->IsSubjectToDebugging()) context_ = Handle<Context>();
 }


Index: src/debug/debug.cc
diff --git a/src/debug/debug.cc b/src/debug/debug.cc
index e789def917e371c1a43c540cfb92c1daa5553b70..b39096618efd76446a275f38512503880d601fee 100644
--- a/src/debug/debug.cc
+++ b/src/debug/debug.cc
@@ -2340,7 +2340,7 @@ void Debug::HandleDebugBreak() {
     Object* fun = it.frame()->function();
     if (fun && fun->IsJSFunction()) {
       // Don't stop in builtin functions.
-      if (JSFunction::cast(fun)->IsBuiltin()) return;
+      if (!JSFunction::cast(fun)->IsSubjectToDebugging()) return;
GlobalObject* global = JSFunction::cast(fun)->context()->global_object();
       // Don't stop in debugger functions.
       if (IsDebugGlobal(global)) return;
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index b3713b644c5dfe9b39339d05a953e4858f6e3aa9..fdf059154b9a856c81070a93363b35845fa76a33 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -6006,18 +6006,19 @@ void SharedFunctionInfo::set_disable_optimization_reason(BailoutReason reason) {
 }


-bool SharedFunctionInfo::IsSubjectToDebugging() {
+bool SharedFunctionInfo::IsBuiltin() {
   Object* script_obj = script();
-  if (script_obj->IsUndefined()) return false;
+  if (script_obj->IsUndefined()) return true;
   Script* script = Script::cast(script_obj);
   Script::Type type = static_cast<Script::Type>(script->type()->value());
-  return type == Script::TYPE_NORMAL;
+  return type != Script::TYPE_NORMAL;
 }


-bool JSFunction::IsBuiltin() {
-  return context()->global_object()->IsJSBuiltinsObject();
-}
+bool SharedFunctionInfo::IsSubjectToDebugging() { return !IsBuiltin(); }
+
+
+bool JSFunction::IsBuiltin() { return shared()->IsBuiltin(); }


 bool JSFunction::IsSubjectToDebugging() {
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index a136a93a5c31a91e33750dc40e9c354fa62d50e4..b01225b3e600e8f63dc381cd354f553659df853f 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -6421,6 +6421,9 @@ class SharedFunctionInfo: public HeapObject {
   // Tells whether this function should be subject to debugging.
   inline bool IsSubjectToDebugging();

+  // Whether this function is defined in native code or extensions.
+  inline bool IsBuiltin();
+
   // Check whether or not this function is inlineable.
   bool IsInlineable();

Index: src/runtime/runtime-debug.cc
diff --git a/src/runtime/runtime-debug.cc b/src/runtime/runtime-debug.cc
index 1cd524f17c64e882141810686f730a46363d14d8..06b78ef2de44b591d72ed9a22c8eaa290ba9374d 100644
--- a/src/runtime/runtime-debug.cc
+++ b/src/runtime/runtime-debug.cc
@@ -533,6 +533,7 @@ RUNTIME_FUNCTION(Runtime_GetFrameDetails) {

   // Get scope info and read from it for local variable information.
Handle<JSFunction> function(JSFunction::cast(frame_inspector.GetFunction()));
+  RUNTIME_ASSERT(function->IsSubjectToDebugging());
   Handle<SharedFunctionInfo> shared(function->shared());
   Handle<ScopeInfo> scope_info(shared->scope_info());
   DCHECK(*scope_info != ScopeInfo::Empty(isolate));
@@ -712,8 +713,8 @@ RUNTIME_FUNCTION(Runtime_GetFrameDetails) {
   // THIS MUST BE DONE LAST SINCE WE MIGHT ADVANCE
   // THE FRAME ITERATOR TO WRAP THE RECEIVER.
   Handle<Object> receiver(it.frame()->receiver(), isolate);
-  if (!receiver->IsJSObject() && is_sloppy(shared->language_mode()) &&
-      !function->IsBuiltin()) {
+  DCHECK(!function->IsBuiltin());
+  if (!receiver->IsJSObject() && is_sloppy(shared->language_mode())) {
     // If the receiver is not a JSObject and the function is not a
     // builtin or strict-mode we have hit an optimization where a
     // value object is not converted into a wrapped JS objects. To
@@ -1637,7 +1638,7 @@ RUNTIME_FUNCTION(Runtime_DebugCallbackSupportsStepping) {
   // or not even a function.
   return isolate->heap()->ToBoolean(
       callback->IsJSFunction() &&
-      (!JSFunction::cast(callback)->IsBuiltin() ||
+      (JSFunction::cast(callback)->IsSubjectToDebugging() ||
        JSFunction::cast(callback)->shared()->bound()));
 }



--
--
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.

Reply via email to