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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: src/d8.cc
diff --git a/src/d8.cc b/src/d8.cc
index c70ff42dc7b511692260b3b4e09f6269424ee430..4dc54c09445bc76e81ff0b052ec9eba0d94a08f7 100644
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -646,33 +646,34 @@ void Shell::Print(const v8::FunctionCallbackInfo<v8::Value>& args) {
void Shell::Write(const v8::FunctionCallbackInfo<v8::Value>& args) {
- for (int i = 0; i < args.Length(); i++) {
- HandleScope handle_scope(args.GetIsolate());
- if (i != 0) {
- printf(" ");
- }
+ FOR_WITH_HANDLE_SCOPE(
+ args.GetIsolate(), int, i = 0, i, i < args.Length(), i++, {
+ if (i != 0) {
+ printf(" ");
+ }
- // Explicitly catch potential exceptions in toString().
- v8::TryCatch try_catch(args.GetIsolate());
- Local<Value> arg = args[i];
- Local<String> str_obj;
+ // Explicitly catch potential exceptions in toString().
+ v8::TryCatch try_catch(args.GetIsolate());
+ Local<Value> arg = args[i];
+ Local<String> str_obj;
- if (arg->IsSymbol()) {
- arg = Local<Symbol>::Cast(arg)->Name();
- }
- if (!arg->ToString(args.GetIsolate()->GetCurrentContext())
- .ToLocal(&str_obj)) {
- try_catch.ReThrow();
- return;
- }
+ if (arg->IsSymbol()) {
+ arg = Local<Symbol>::Cast(arg)->Name();
+ }
+ if (!arg->ToString(args.GetIsolate()->GetCurrentContext())
+ .ToLocal(&str_obj)) {
+ try_catch.ReThrow();
+ return;
+ }
- v8::String::Utf8Value str(str_obj);
- int n = static_cast<int>(fwrite(*str, sizeof(**str), str.length(), stdout));
- if (n != str.length()) {
- printf("Error in fwrite\n");
- Exit(1);
- }
- }
+ v8::String::Utf8Value str(str_obj);
+ int n =
+ static_cast<int>(fwrite(*str, sizeof(**str), str.length(), stdout));
+ if (n != str.length()) {
+ printf("Error in fwrite\n");
+ Exit(1);
+ }
+ });
}
@@ -729,27 +730,27 @@ Local<String> Shell::ReadFromStdin(Isolate* isolate) {
void Shell::Load(const v8::FunctionCallbackInfo<v8::Value>& args) {
- for (int i = 0; i < args.Length(); i++) {
- HandleScope handle_scope(args.GetIsolate());
- String::Utf8Value file(args[i]);
- if (*file == NULL) {
- Throw(args.GetIsolate(), "Error loading file");
- return;
- }
- Local<String> source = ReadFile(args.GetIsolate(), *file);
- if (source.IsEmpty()) {
- Throw(args.GetIsolate(), "Error loading file");
- return;
- }
- if (!ExecuteString(
- args.GetIsolate(), source,
- String::NewFromUtf8(args.GetIsolate(), *file,
- NewStringType::kNormal).ToLocalChecked(),
- false, true)) {
- Throw(args.GetIsolate(), "Error executing file");
- return;
- }
- }
+ FOR_WITH_HANDLE_SCOPE(
+ args.GetIsolate(), int, i = 0, i, i < args.Length(), i++, {
+ String::Utf8Value file(args[i]);
+ if (*file == NULL) {
+ Throw(args.GetIsolate(), "Error loading file");
+ return;
+ }
+ Local<String> source = ReadFile(args.GetIsolate(), *file);
+ if (source.IsEmpty()) {
+ Throw(args.GetIsolate(), "Error loading file");
+ return;
+ }
+ if (!ExecuteString(args.GetIsolate(), source,
+ String::NewFromUtf8(args.GetIsolate(), *file,
+ NewStringType::kNormal)
+ .ToLocalChecked(),
+ false, true)) {
+ Throw(args.GetIsolate(), "Error executing file");
+ return;
+ }
+ });
}
« 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