Commit b58cfd48 authored by yangguo@chromium.org's avatar yangguo@chromium.org

Avoid GC when printing shared function info.

R=mstarzinger@chromium.org
BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com/10828048

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12210 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 0923cacc
......@@ -794,7 +794,14 @@ void SharedFunctionInfo::SharedFunctionInfoPrint(FILE* out) {
code()->ShortPrint(out);
if (HasSourceCode()) {
PrintF(out, "\n - source code = ");
GetSourceCode()->ShortPrint(out);
String* source = String::cast(Script::cast(script())->source());
int start = start_position();
int length = end_position() - start;
SmartArrayPointer<char> source_string =
source->ToCString(DISALLOW_NULLS,
FAST_STRING_TRAVERSAL,
start, length, NULL);
PrintF(out, "%s", *source_string);
}
// Script files are often large, hard to read.
// PrintF(out, "\n - script =");
......
......@@ -1966,3 +1966,21 @@ TEST(Regress2237) {
HEAP->CollectAllGarbage(Heap::kNoGCFlags);
CHECK(SlicedString::cast(*slice)->parent()->IsSeqAsciiString());
}
#ifdef OBJECT_PRINT
TEST(PrintSharedFunctionInfo) {
InitializeVM();
v8::HandleScope scope;
const char* source = "f = function() { return 987654321; }\n"
"g = function() { return 123456789; }\n";
CompileRun(source);
Handle<JSFunction> g =
v8::Utils::OpenHandle(
*v8::Handle<v8::Function>::Cast(
v8::Context::GetCurrent()->Global()->Get(v8_str("g"))));
AssertNoAllocation no_alloc;
g->shared()->PrintLn();
}
#endif // OBJECT_PRINT
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment