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

Side by Side Diff: src/d8.cc

Issue 196793013: Revert "New Compilation API, part 1" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 9 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 | « src/api.cc ('k') | src/heap.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 #else 198 #else
199 bool FLAG_debugger = false; 199 bool FLAG_debugger = false;
200 #endif // !V8_SHARED && ENABLE_DEBUGGER_SUPPORT 200 #endif // !V8_SHARED && ENABLE_DEBUGGER_SUPPORT
201 HandleScope handle_scope(isolate); 201 HandleScope handle_scope(isolate);
202 TryCatch try_catch; 202 TryCatch try_catch;
203 options.script_executed = true; 203 options.script_executed = true;
204 if (FLAG_debugger) { 204 if (FLAG_debugger) {
205 // When debugging make exceptions appear to be uncaught. 205 // When debugging make exceptions appear to be uncaught.
206 try_catch.SetVerbose(true); 206 try_catch.SetVerbose(true);
207 } 207 }
208 ScriptOrigin origin(name); 208 Handle<Script> script = Script::New(source, name);
209 Handle<UnboundScript> script = ScriptCompiler::CompileUnbound(
210 isolate, ScriptCompiler::Source(source, origin));
211 if (script.IsEmpty()) { 209 if (script.IsEmpty()) {
212 // Print errors that happened during compilation. 210 // Print errors that happened during compilation.
213 if (report_exceptions && !FLAG_debugger) 211 if (report_exceptions && !FLAG_debugger)
214 ReportException(isolate, &try_catch); 212 ReportException(isolate, &try_catch);
215 return false; 213 return false;
216 } else { 214 } else {
217 PerIsolateData* data = PerIsolateData::Get(isolate); 215 PerIsolateData* data = PerIsolateData::Get(isolate);
218 Local<Context> realm = 216 Local<Context> realm =
219 Local<Context>::New(isolate, data->realms_[data->realm_current_]); 217 Local<Context>::New(isolate, data->realms_[data->realm_current_]);
220 realm->Enter(); 218 realm->Enter();
221 Handle<Value> result = script->BindToCurrentContext()->Run(); 219 Handle<Value> result = script->Run();
222 realm->Exit(); 220 realm->Exit();
223 data->realm_current_ = data->realm_switch_; 221 data->realm_current_ = data->realm_switch_;
224 if (result.IsEmpty()) { 222 if (result.IsEmpty()) {
225 ASSERT(try_catch.HasCaught()); 223 ASSERT(try_catch.HasCaught());
226 // Print errors that happened during execution. 224 // Print errors that happened during execution.
227 if (report_exceptions && !FLAG_debugger) 225 if (report_exceptions && !FLAG_debugger)
228 ReportException(isolate, &try_catch); 226 ReportException(isolate, &try_catch);
229 return false; 227 return false;
230 } else { 228 } else {
231 ASSERT(!try_catch.HasCaught()); 229 ASSERT(!try_catch.HasCaught());
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 // Realm.eval(i, s) evaluates s in realm i and returns the result. 398 // Realm.eval(i, s) evaluates s in realm i and returns the result.
401 void Shell::RealmEval(const v8::FunctionCallbackInfo<v8::Value>& args) { 399 void Shell::RealmEval(const v8::FunctionCallbackInfo<v8::Value>& args) {
402 Isolate* isolate = args.GetIsolate(); 400 Isolate* isolate = args.GetIsolate();
403 PerIsolateData* data = PerIsolateData::Get(isolate); 401 PerIsolateData* data = PerIsolateData::Get(isolate);
404 int index = data->RealmIndexOrThrow(args, 0); 402 int index = data->RealmIndexOrThrow(args, 0);
405 if (index == -1) return; 403 if (index == -1) return;
406 if (args.Length() < 2 || !args[1]->IsString()) { 404 if (args.Length() < 2 || !args[1]->IsString()) {
407 Throw(args.GetIsolate(), "Invalid argument"); 405 Throw(args.GetIsolate(), "Invalid argument");
408 return; 406 return;
409 } 407 }
410 Handle<UnboundScript> script = ScriptCompiler::CompileUnbound( 408 Handle<Script> script = Script::New(args[1]->ToString());
411 isolate, ScriptCompiler::Source(args[1]->ToString()));
412 if (script.IsEmpty()) return; 409 if (script.IsEmpty()) return;
413 Local<Context> realm = Local<Context>::New(isolate, data->realms_[index]); 410 Local<Context> realm = Local<Context>::New(isolate, data->realms_[index]);
414 realm->Enter(); 411 realm->Enter();
415 Handle<Value> result = script->BindToCurrentContext()->Run(); 412 Handle<Value> result = script->Run();
416 realm->Exit(); 413 realm->Exit();
417 args.GetReturnValue().Set(result); 414 args.GetReturnValue().Set(result);
418 } 415 }
419 416
420 417
421 // Realm.shared is an accessor for a single shared value across realms. 418 // Realm.shared is an accessor for a single shared value across realms.
422 void Shell::RealmSharedGet(Local<String> property, 419 void Shell::RealmSharedGet(Local<String> property,
423 const PropertyCallbackInfo<Value>& info) { 420 const PropertyCallbackInfo<Value>& info) {
424 Isolate* isolate = info.GetIsolate(); 421 Isolate* isolate = info.GetIsolate();
425 PerIsolateData* data = PerIsolateData::Get(isolate); 422 PerIsolateData* data = PerIsolateData::Get(isolate);
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 i::Vector<const char> shell_source = 799 i::Vector<const char> shell_source =
803 i::NativesCollection<i::D8>::GetRawScriptSource(source_index); 800 i::NativesCollection<i::D8>::GetRawScriptSource(source_index);
804 i::Vector<const char> shell_source_name = 801 i::Vector<const char> shell_source_name =
805 i::NativesCollection<i::D8>::GetScriptName(source_index); 802 i::NativesCollection<i::D8>::GetScriptName(source_index);
806 Handle<String> source = 803 Handle<String> source =
807 String::NewFromUtf8(isolate, shell_source.start(), String::kNormalString, 804 String::NewFromUtf8(isolate, shell_source.start(), String::kNormalString,
808 shell_source.length()); 805 shell_source.length());
809 Handle<String> name = 806 Handle<String> name =
810 String::NewFromUtf8(isolate, shell_source_name.start(), 807 String::NewFromUtf8(isolate, shell_source_name.start(),
811 String::kNormalString, shell_source_name.length()); 808 String::kNormalString, shell_source_name.length());
812 ScriptOrigin origin(name); 809 Handle<Script> script = Script::Compile(source, name);
813 Handle<Script> script = Script::Compile(source, &origin);
814 script->Run(); 810 script->Run();
815 // Mark the d8 shell script as native to avoid it showing up as normal source 811 // Mark the d8 shell script as native to avoid it showing up as normal source
816 // in the debugger. 812 // in the debugger.
817 i::Handle<i::Object> compiled_script = Utils::OpenHandle(*script); 813 i::Handle<i::Object> compiled_script = Utils::OpenHandle(*script);
818 i::Handle<i::Script> script_object = compiled_script->IsJSFunction() 814 i::Handle<i::Script> script_object = compiled_script->IsJSFunction()
819 ? i::Handle<i::Script>(i::Script::cast( 815 ? i::Handle<i::Script>(i::Script::cast(
820 i::JSFunction::cast(*compiled_script)->shared()->script())) 816 i::JSFunction::cast(*compiled_script)->shared()->script()))
821 : i::Handle<i::Script>(i::Script::cast( 817 : i::Handle<i::Script>(i::Script::cast(
822 i::SharedFunctionInfo::cast(*compiled_script)->script())); 818 i::SharedFunctionInfo::cast(*compiled_script)->script()));
823 script_object->set_type(i::Smi::FromInt(i::Script::TYPE_NATIVE)); 819 script_object->set_type(i::Smi::FromInt(i::Script::TYPE_NATIVE));
(...skipping 943 matching lines...) Expand 10 before | Expand all | Expand 10 after
1767 } 1763 }
1768 1764
1769 } // namespace v8 1765 } // namespace v8
1770 1766
1771 1767
1772 #ifndef GOOGLE3 1768 #ifndef GOOGLE3
1773 int main(int argc, char* argv[]) { 1769 int main(int argc, char* argv[]) {
1774 return v8::Shell::Main(argc, argv); 1770 return v8::Shell::Main(argc, argv);
1775 } 1771 }
1776 #endif 1772 #endif
OLDNEW
« no previous file with comments | « src/api.cc ('k') | src/heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698