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

Side by Side Diff: src/d8.cc

Issue 1785403002: [runtime] split up loops with HandleScopes (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: adding loop var type Created 4 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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 5
6 // Defined when linking against shared lib on Windows. 6 // Defined when linking against shared lib on Windows.
7 #if defined(USING_V8_SHARED) && !defined(V8_SHARED) 7 #if defined(USING_V8_SHARED) && !defined(V8_SHARED)
8 #define V8_SHARED 8 #define V8_SHARED
9 #endif 9 #endif
10 10
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 639
640 640
641 void Shell::Print(const v8::FunctionCallbackInfo<v8::Value>& args) { 641 void Shell::Print(const v8::FunctionCallbackInfo<v8::Value>& args) {
642 Write(args); 642 Write(args);
643 printf("\n"); 643 printf("\n");
644 fflush(stdout); 644 fflush(stdout);
645 } 645 }
646 646
647 647
648 void Shell::Write(const v8::FunctionCallbackInfo<v8::Value>& args) { 648 void Shell::Write(const v8::FunctionCallbackInfo<v8::Value>& args) {
649 for (int i = 0; i < args.Length(); i++) { 649 FOR_WITH_HANDLE_SCOPE(
650 HandleScope handle_scope(args.GetIsolate()); 650 args.GetIsolate(), int, i = 0, i, i < args.Length(), i++, {
651 if (i != 0) { 651 if (i != 0) {
652 printf(" "); 652 printf(" ");
653 } 653 }
654 654
655 // Explicitly catch potential exceptions in toString(). 655 // Explicitly catch potential exceptions in toString().
656 v8::TryCatch try_catch(args.GetIsolate()); 656 v8::TryCatch try_catch(args.GetIsolate());
657 Local<Value> arg = args[i]; 657 Local<Value> arg = args[i];
658 Local<String> str_obj; 658 Local<String> str_obj;
659 659
660 if (arg->IsSymbol()) { 660 if (arg->IsSymbol()) {
661 arg = Local<Symbol>::Cast(arg)->Name(); 661 arg = Local<Symbol>::Cast(arg)->Name();
662 } 662 }
663 if (!arg->ToString(args.GetIsolate()->GetCurrentContext()) 663 if (!arg->ToString(args.GetIsolate()->GetCurrentContext())
664 .ToLocal(&str_obj)) { 664 .ToLocal(&str_obj)) {
665 try_catch.ReThrow(); 665 try_catch.ReThrow();
666 return; 666 return;
667 } 667 }
668 668
669 v8::String::Utf8Value str(str_obj); 669 v8::String::Utf8Value str(str_obj);
670 int n = static_cast<int>(fwrite(*str, sizeof(**str), str.length(), stdout)); 670 int n =
671 if (n != str.length()) { 671 static_cast<int>(fwrite(*str, sizeof(**str), str.length(), stdout));
672 printf("Error in fwrite\n"); 672 if (n != str.length()) {
673 Exit(1); 673 printf("Error in fwrite\n");
674 } 674 Exit(1);
675 } 675 }
676 });
676 } 677 }
677 678
678 679
679 void Shell::Read(const v8::FunctionCallbackInfo<v8::Value>& args) { 680 void Shell::Read(const v8::FunctionCallbackInfo<v8::Value>& args) {
680 String::Utf8Value file(args[0]); 681 String::Utf8Value file(args[0]);
681 if (*file == NULL) { 682 if (*file == NULL) {
682 Throw(args.GetIsolate(), "Error loading file"); 683 Throw(args.GetIsolate(), "Error loading file");
683 return; 684 return;
684 } 685 }
685 Local<String> source = ReadFile(args.GetIsolate(), *file); 686 Local<String> source = ReadFile(args.GetIsolate(), *file);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 return String::Concat( 723 return String::Concat(
723 accumulator, 724 accumulator,
724 String::NewFromUtf8(isolate, buffer, NewStringType::kNormal, 725 String::NewFromUtf8(isolate, buffer, NewStringType::kNormal,
725 length - 1).ToLocalChecked()); 726 length - 1).ToLocalChecked());
726 } 727 }
727 } 728 }
728 } 729 }
729 730
730 731
731 void Shell::Load(const v8::FunctionCallbackInfo<v8::Value>& args) { 732 void Shell::Load(const v8::FunctionCallbackInfo<v8::Value>& args) {
732 for (int i = 0; i < args.Length(); i++) { 733 FOR_WITH_HANDLE_SCOPE(
733 HandleScope handle_scope(args.GetIsolate()); 734 args.GetIsolate(), int, i = 0, i, i < args.Length(), i++, {
734 String::Utf8Value file(args[i]); 735 String::Utf8Value file(args[i]);
735 if (*file == NULL) { 736 if (*file == NULL) {
736 Throw(args.GetIsolate(), "Error loading file"); 737 Throw(args.GetIsolate(), "Error loading file");
737 return; 738 return;
738 } 739 }
739 Local<String> source = ReadFile(args.GetIsolate(), *file); 740 Local<String> source = ReadFile(args.GetIsolate(), *file);
740 if (source.IsEmpty()) { 741 if (source.IsEmpty()) {
741 Throw(args.GetIsolate(), "Error loading file"); 742 Throw(args.GetIsolate(), "Error loading file");
742 return; 743 return;
743 } 744 }
744 if (!ExecuteString( 745 if (!ExecuteString(args.GetIsolate(), source,
745 args.GetIsolate(), source, 746 String::NewFromUtf8(args.GetIsolate(), *file,
746 String::NewFromUtf8(args.GetIsolate(), *file, 747 NewStringType::kNormal)
747 NewStringType::kNormal).ToLocalChecked(), 748 .ToLocalChecked(),
748 false, true)) { 749 false, true)) {
749 Throw(args.GetIsolate(), "Error executing file"); 750 Throw(args.GetIsolate(), "Error executing file");
750 return; 751 return;
751 } 752 }
752 } 753 });
753 } 754 }
754 755
755 756
756 #ifndef V8_SHARED 757 #ifndef V8_SHARED
757 void Shell::WorkerNew(const v8::FunctionCallbackInfo<v8::Value>& args) { 758 void Shell::WorkerNew(const v8::FunctionCallbackInfo<v8::Value>& args) {
758 Isolate* isolate = args.GetIsolate(); 759 Isolate* isolate = args.GetIsolate();
759 HandleScope handle_scope(isolate); 760 HandleScope handle_scope(isolate);
760 if (args.Length() < 1 || !args[0]->IsString()) { 761 if (args.Length() < 1 || !args[0]->IsString()) {
761 Throw(args.GetIsolate(), "1st argument must be string"); 762 Throw(args.GetIsolate(), "1st argument must be string");
762 return; 763 return;
(...skipping 1777 matching lines...) Expand 10 before | Expand all | Expand 10 after
2540 } 2541 }
2541 2542
2542 } // namespace v8 2543 } // namespace v8
2543 2544
2544 2545
2545 #ifndef GOOGLE3 2546 #ifndef GOOGLE3
2546 int main(int argc, char* argv[]) { 2547 int main(int argc, char* argv[]) {
2547 return v8::Shell::Main(argc, argv); 2548 return v8::Shell::Main(argc, argv);
2548 } 2549 }
2549 #endif 2550 #endif
OLDNEW
« src/builtins.cc ('K') | « src/builtins.cc ('k') | src/debug/debug-scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698