Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: Source/bindings/v8/V8ScriptRunner.cpp

Issue 15975002: Implement V8ScriptRunner::callFunction() Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/bindings/v8/V8ScriptRunner.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 } 103 }
104 104
105 v8::Local<v8::Value> V8ScriptRunner::compileAndRunInternalScript(v8::Handle<v8:: String> source, v8::Isolate* isolate, v8::Local<v8::Context> context, const Stri ng& fileName, const TextPosition& scriptStartPosition, v8::ScriptData* scriptDat a) 105 v8::Local<v8::Value> V8ScriptRunner::compileAndRunInternalScript(v8::Handle<v8:: String> source, v8::Isolate* isolate, v8::Local<v8::Context> context, const Stri ng& fileName, const TextPosition& scriptStartPosition, v8::ScriptData* scriptDat a)
106 { 106 {
107 TRACE_EVENT0("v8", "v8.run"); 107 TRACE_EVENT0("v8", "v8.run");
108 v8::Local<v8::Value> result; 108 v8::Local<v8::Value> result;
109 if (context.IsEmpty()) 109 if (context.IsEmpty())
110 context = v8::Context::New(isolate); 110 context = v8::Context::New(isolate);
111 if (context.IsEmpty()) 111 if (context.IsEmpty())
112 return result; 112 return result;
113 {
114 v8::Context::Scope scope(context);
115 v8::Handle<v8::Script> script = V8ScriptRunner::compileScript(source, fi leName, scriptStartPosition, scriptData, isolate);
116 if (script.IsEmpty())
117 return result;
118 113
119 V8RecursionScope::MicrotaskSuppression recursionScope; 114 v8::Context::Scope scope(context);
120 result = script->Run(); 115 v8::Handle<v8::Script> script = V8ScriptRunner::compileScript(source, fileNa me, scriptStartPosition, scriptData, isolate);
121 } 116 if (script.IsEmpty())
117 return result;
118
119 V8RecursionScope::MicrotaskSuppression recursionScope;
120 result = script->Run();
122 return result; 121 return result;
123 } 122 }
124 123
124 static String functionInfo(const v8::Handle<v8::Function> function)
125 {
126 String resourceName = "undefined";
127 int lineNumber = 1;
128 v8::ScriptOrigin origin = function->GetScriptOrigin();
129 if (!origin.ResourceName().IsEmpty()) {
130 resourceName = toWebCoreString(origin.ResourceName());
131 lineNumber = function->GetScriptLineNumber() + 1;
132 }
133
134 StringBuilder builder;
135 builder.append(resourceName);
136 builder.append(':');
137 builder.appendNumber(lineNumber);
138 return builder.toString();
139 }
140
141 v8::Local<v8::Value> V8ScriptRunner::callFunction(v8::Handle<v8::Function> funct ion, ScriptExecutionContext* context, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8::Value> args[])
142 {
143 TRACE_EVENT0("v8", "v8.callFunction");
haraken 2013/05/24 04:22:32 Previously this was: TRACE_EVENT1("v8", "v8.cal
144 V8GCController::checkMemoryUsage();
145
146 if (V8RecursionScope::recursionLevel() >= kMaxRecursionDepth)
147 return handleMaxRecursionDepthExceeded();
148
149 V8RecursionScope recursionScope(context);
150 v8::Local<v8::Value> result = function->Call(receiver, argc, args);
151
152 crashIfV8IsDead();
153 return result;
154 }
155
125 } // namespace WebCore 156 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/v8/V8ScriptRunner.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698