Reviewers: Jakob,
Description:
Fix assertion scope in Runtime_GetScript.
The HeapIterator implies DisallowHeapAllocation, but Script::GetWrapper
may allocate.
LOG=N
[email protected]
BUG=chromium:410033
Please review this at https://codereview.chromium.org/680283002/
Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+21, -39 lines):
M src/runtime/runtime-debug.cc
A + test/mjsunit/regress/regress-crbug-410033.js
Index: src/runtime/runtime-debug.cc
diff --git a/src/runtime/runtime-debug.cc b/src/runtime/runtime-debug.cc
index
15551066e99bbe65df986880728f3e754df837e3..2de372f66ba8caf53816f7ee4187dabad4aff93e
100644
--- a/src/runtime/runtime-debug.cc
+++ b/src/runtime/runtime-debug.cc
@@ -2614,48 +2614,30 @@ RUNTIME_FUNCTION(Runtime_GetHeapUsage) {
// 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);
}
Index: test/mjsunit/regress/regress-crbug-410033.js
diff --git a/test/mjsunit/regress/string-compare-memcmp.js
b/test/mjsunit/regress/regress-crbug-410033.js
similarity index 64%
copy from test/mjsunit/regress/string-compare-memcmp.js
copy to test/mjsunit/regress/regress-crbug-410033.js
index
45f47343ee84fcd71c94d63a32210c83ca8c091d..1f9b37494cfb74a3450958153e2328cddab951bc
100644
--- a/test/mjsunit/regress/string-compare-memcmp.js
+++ b/test/mjsunit/regress/regress-crbug-410033.js
@@ -2,6 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// Flags: --allow-natives-syntax
+// Flags: --allow-natives-syntax --expose-gc
-assertEquals(-1, %StringCompare("abc\u0102", "abc\u0201"));
+%GetScript('v8/gc');
--
--
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.