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

Side by Side Diff: src/d8.cc

Issue 6685088: Merge isolates to bleeding_edge. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 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/cpu-profiler.cc ('k') | src/d8-debug.h » ('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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 11 matching lines...) Expand all
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 28
29 #include <stdlib.h> 29 #include <stdlib.h>
30 #include <errno.h> 30 #include <errno.h>
31 31
32 #include "v8.h"
33
32 #include "d8.h" 34 #include "d8.h"
33 #include "d8-debug.h" 35 #include "d8-debug.h"
34 #include "debug.h" 36 #include "debug.h"
35 #include "api.h" 37 #include "api.h"
36 #include "natives.h" 38 #include "natives.h"
37 #include "platform.h" 39 #include "platform.h"
38 40
39 41
40 namespace v8 { 42 namespace v8 {
41 43
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 Handle<ObjectTemplate> os_templ = ObjectTemplate::New(); 436 Handle<ObjectTemplate> os_templ = ObjectTemplate::New();
435 AddOSMethods(os_templ); 437 AddOSMethods(os_templ);
436 global_template->Set(String::New("os"), os_templ); 438 global_template->Set(String::New("os"), os_templ);
437 439
438 utility_context_ = Context::New(NULL, global_template); 440 utility_context_ = Context::New(NULL, global_template);
439 utility_context_->SetSecurityToken(Undefined()); 441 utility_context_->SetSecurityToken(Undefined());
440 Context::Scope utility_scope(utility_context_); 442 Context::Scope utility_scope(utility_context_);
441 443
442 i::JSArguments js_args = i::FLAG_js_arguments; 444 i::JSArguments js_args = i::FLAG_js_arguments;
443 i::Handle<i::FixedArray> arguments_array = 445 i::Handle<i::FixedArray> arguments_array =
444 i::Factory::NewFixedArray(js_args.argc()); 446 FACTORY->NewFixedArray(js_args.argc());
445 for (int j = 0; j < js_args.argc(); j++) { 447 for (int j = 0; j < js_args.argc(); j++) {
446 i::Handle<i::String> arg = 448 i::Handle<i::String> arg =
447 i::Factory::NewStringFromUtf8(i::CStrVector(js_args[j])); 449 FACTORY->NewStringFromUtf8(i::CStrVector(js_args[j]));
448 arguments_array->set(j, *arg); 450 arguments_array->set(j, *arg);
449 } 451 }
450 i::Handle<i::JSArray> arguments_jsarray = 452 i::Handle<i::JSArray> arguments_jsarray =
451 i::Factory::NewJSArrayWithElements(arguments_array); 453 FACTORY->NewJSArrayWithElements(arguments_array);
452 global_template->Set(String::New("arguments"), 454 global_template->Set(String::New("arguments"),
453 Utils::ToLocal(arguments_jsarray)); 455 Utils::ToLocal(arguments_jsarray));
454 456
455 #ifdef ENABLE_DEBUGGER_SUPPORT 457 #ifdef ENABLE_DEBUGGER_SUPPORT
456 // Install the debugger object in the utility scope 458 // Install the debugger object in the utility scope
457 i::Debug::Load(); 459 i::Debug* debug = i::Isolate::Current()->debug();
458 i::Handle<i::JSObject> debug 460 debug->Load();
459 = i::Handle<i::JSObject>(i::Debug::debug_context()->global()); 461 i::Handle<i::JSObject> js_debug
462 = i::Handle<i::JSObject>(debug->debug_context()->global());
460 utility_context_->Global()->Set(String::New("$debug"), 463 utility_context_->Global()->Set(String::New("$debug"),
461 Utils::ToLocal(debug)); 464 Utils::ToLocal(js_debug));
462 #endif 465 #endif
463 466
464 // Run the d8 shell utility script in the utility context 467 // Run the d8 shell utility script in the utility context
465 int source_index = i::NativesCollection<i::D8>::GetIndex("d8"); 468 int source_index = i::NativesCollection<i::D8>::GetIndex("d8");
466 i::Vector<const char> shell_source 469 i::Vector<const char> shell_source
467 = i::NativesCollection<i::D8>::GetScriptSource(source_index); 470 = i::NativesCollection<i::D8>::GetScriptSource(source_index);
468 i::Vector<const char> shell_source_name 471 i::Vector<const char> shell_source_name
469 = i::NativesCollection<i::D8>::GetScriptName(source_index); 472 = i::NativesCollection<i::D8>::GetScriptName(source_index);
470 Handle<String> source = String::New(shell_source.start(), 473 Handle<String> source = String::New(shell_source.start(),
471 shell_source.length()); 474 shell_source.length());
(...skipping 11 matching lines...) Expand all
483 : i::Handle<i::Script>(i::Script::cast( 486 : i::Handle<i::Script>(i::Script::cast(
484 i::SharedFunctionInfo::cast(*compiled_script)->script())); 487 i::SharedFunctionInfo::cast(*compiled_script)->script()));
485 script_object->set_type(i::Smi::FromInt(i::Script::TYPE_NATIVE)); 488 script_object->set_type(i::Smi::FromInt(i::Script::TYPE_NATIVE));
486 489
487 // Create the evaluation context 490 // Create the evaluation context
488 evaluation_context_ = Context::New(NULL, global_template); 491 evaluation_context_ = Context::New(NULL, global_template);
489 evaluation_context_->SetSecurityToken(Undefined()); 492 evaluation_context_->SetSecurityToken(Undefined());
490 493
491 #ifdef ENABLE_DEBUGGER_SUPPORT 494 #ifdef ENABLE_DEBUGGER_SUPPORT
492 // Set the security token of the debug context to allow access. 495 // Set the security token of the debug context to allow access.
493 i::Debug::debug_context()->set_security_token(i::Heap::undefined_value()); 496 debug->debug_context()->set_security_token(HEAP->undefined_value());
494 497
495 // Start the debugger agent if requested. 498 // Start the debugger agent if requested.
496 if (i::FLAG_debugger_agent) { 499 if (i::FLAG_debugger_agent) {
497 v8::Debug::EnableAgent("d8 shell", i::FLAG_debugger_port, true); 500 v8::Debug::EnableAgent("d8 shell", i::FLAG_debugger_port, true);
498 } 501 }
499 502
500 // Start the in-process debugger if requested. 503 // Start the in-process debugger if requested.
501 if (i::FLAG_debugger && !i::FLAG_debugger_agent) { 504 if (i::FLAG_debugger && !i::FLAG_debugger_agent) {
502 v8::Debug::SetDebugEventListener(HandleDebugEvent); 505 v8::Debug::SetDebugEventListener(HandleDebugEvent);
503 } 506 }
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 Handle<String> name = String::New("(d8)"); 602 Handle<String> name = String::New("(d8)");
600 ExecuteString(String::New(*input), name, true, true); 603 ExecuteString(String::New(*input), name, true, true);
601 } 604 }
602 editor->Close(); 605 editor->Close();
603 printf("\n"); 606 printf("\n");
604 } 607 }
605 608
606 609
607 class ShellThread : public i::Thread { 610 class ShellThread : public i::Thread {
608 public: 611 public:
609 ShellThread(int no, i::Vector<const char> files) 612 ShellThread(i::Isolate* isolate, int no, i::Vector<const char> files)
610 : Thread("d8:ShellThread"), 613 : Thread(isolate, "d8:ShellThread"),
611 no_(no), files_(files) { } 614 no_(no), files_(files) { }
612 virtual void Run(); 615 virtual void Run();
613 private: 616 private:
614 int no_; 617 int no_;
615 i::Vector<const char> files_; 618 i::Vector<const char> files_;
616 }; 619 };
617 620
618 621
619 void ShellThread::Run() { 622 void ShellThread::Run() {
620 // Prepare the context for this thread. 623 // Prepare the context for this thread.
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 if (!ExecuteString(source, file_name, false, true)) { 735 if (!ExecuteString(source, file_name, false, true)) {
733 OnExit(); 736 OnExit();
734 return 1; 737 return 1;
735 } 738 }
736 i++; 739 i++;
737 } else if (strcmp(str, "-p") == 0 && i + 1 < argc) { 740 } else if (strcmp(str, "-p") == 0 && i + 1 < argc) {
738 int size = 0; 741 int size = 0;
739 const char* files = ReadChars(argv[++i], &size); 742 const char* files = ReadChars(argv[++i], &size);
740 if (files == NULL) return 1; 743 if (files == NULL) return 1;
741 ShellThread* thread = 744 ShellThread* thread =
742 new ShellThread(threads.length(), 745 new ShellThread(i::Isolate::Current(),
746 threads.length(),
743 i::Vector<const char>(files, size)); 747 i::Vector<const char>(files, size));
744 thread->Start(); 748 thread->Start();
745 threads.Add(thread); 749 threads.Add(thread);
746 } else { 750 } else {
747 // Use all other arguments as names of files to load and run. 751 // Use all other arguments as names of files to load and run.
748 HandleScope handle_scope; 752 HandleScope handle_scope;
749 Handle<String> file_name = v8::String::New(str); 753 Handle<String> file_name = v8::String::New(str);
750 Handle<String> source = ReadFile(str); 754 Handle<String> source = ReadFile(str);
751 if (source.IsEmpty()) { 755 if (source.IsEmpty()) {
752 printf("Error reading '%s'\n", str); 756 printf("Error reading '%s'\n", str);
(...skipping 30 matching lines...) Expand all
783 return 0; 787 return 0;
784 } 788 }
785 789
786 790
787 } // namespace v8 791 } // namespace v8
788 792
789 793
790 int main(int argc, char* argv[]) { 794 int main(int argc, char* argv[]) {
791 return v8::Shell::Main(argc, argv); 795 return v8::Shell::Main(argc, argv);
792 } 796 }
OLDNEW
« no previous file with comments | « src/cpu-profiler.cc ('k') | src/d8-debug.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698