Revision: 25001
Author: [email protected]
Date: Thu Oct 30 07:25:20 2014 UTC
Log: Fix assertion scope in Runtime_GetScript.
The HeapIterator implies DisallowHeapAllocation, but Script::GetWrapper
may allocate.
LOG=N
[email protected]
BUG=chromium:410033
Review URL: https://codereview.chromium.org/680283002
https://code.google.com/p/v8/source/detail?r=25001
Added:
/branches/bleeding_edge/test/mjsunit/regress/regress-crbug-410033.js
Modified:
/branches/bleeding_edge/src/runtime/runtime-debug.cc
=======================================
--- /dev/null
+++ /branches/bleeding_edge/test/mjsunit/regress/regress-crbug-410033.js
Thu Oct 30 07:25:20 2014 UTC
@@ -0,0 +1,7 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --allow-natives-syntax --expose-gc
+
+%GetScript('v8/gc');
=======================================
--- /branches/bleeding_edge/src/runtime/runtime-debug.cc Tue Oct 28
10:00:37 2014 UTC
+++ /branches/bleeding_edge/src/runtime/runtime-debug.cc Thu Oct 30
07:25:20 2014 UTC
@@ -2614,48 +2614,30 @@
// traversals might be required rendering this operation as a rather slow
// operation. However for setting break points which is normally done
through
// some kind of user interaction the performance is not crucial.
-static Handle<Object> Runtime_GetScriptFromScriptName(
- Handle<String> script_name) {
- // Scan the heap for Script objects to find the script with the requested
- // script data.
- Handle<Script> script;
- Factory* factory = script_name->GetIsolate()->factory();
- Heap* heap = script_name->GetHeap();
- HeapIterator iterator(heap);
- HeapObject* obj = NULL;
- while (script.is_null() && ((obj = iterator.next()) != NULL)) {
- // If a script is found check if it has the script data requested.
- if (obj->IsScript()) {
- if (Script::cast(obj)->name()->IsString()) {
- if (String::cast(Script::cast(obj)->name())->Equals(*script_name))
{
- script = Handle<Script>(Script::cast(obj));
- }
- }
- }
- }
-
- // If no script with the requested script data is found return undefined.
- if (script.is_null()) return factory->undefined_value();
-
- // Return the script found.
- return Script::GetWrapper(script);
-}
-
-
-// Get the script object from script data. NOTE: Regarding performance
-// see the NOTE for GetScriptFromScriptData.
-// args[0]: script data for the script to find the source for
RUNTIME_FUNCTION(Runtime_GetScript) {
HandleScope scope(isolate);
-
DCHECK(args.length() == 1);
+ CONVERT_ARG_HANDLE_CHECKED(String, script_name, 0);
- CONVERT_ARG_CHECKED(String, script_name, 0);
+ Handle<Script> found;
+ Heap* heap = isolate->heap();
+ {
+ HeapIterator iterator(heap);
+ HeapObject* obj = NULL;
+ while ((obj = iterator.next()) != NULL) {
+ if (!obj->IsScript()) continue;
+ Script* script = Script::cast(obj);
+ if (!script->name()->IsString()) continue;
+ String* name = String::cast(script->name());
+ if (name->Equals(*script_name)) {
+ found = Handle<Script>(script, isolate);
+ break;
+ }
+ }
+ }
- // Find the requested script.
- Handle<Object> result =
- Runtime_GetScriptFromScriptName(Handle<String>(script_name));
- return *result;
+ if (found.is_null()) return heap->undefined_value();
+ return *Script::GetWrapper(found);
}
--
--
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.