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

Side by Side Diff: src/isolate.cc

Issue 1126043004: Migrate error messages, part 10. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fixed and rebased Created 5 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
« no previous file with comments | « src/ic/ic.cc ('k') | src/json.js » ('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 // 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 #include <stdlib.h> 5 #include <stdlib.h>
6 6
7 #include <fstream> // NOLINT(readability/streams) 7 #include <fstream> // NOLINT(readability/streams)
8 #include <sstream> 8 #include <sstream>
9 9
10 #include "src/v8.h" 10 #include "src/v8.h"
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 Handle<Object> Isolate::CaptureSimpleStackTrace(Handle<JSObject> error_object, 334 Handle<Object> Isolate::CaptureSimpleStackTrace(Handle<JSObject> error_object,
335 Handle<Object> caller) { 335 Handle<Object> caller) {
336 // Get stack trace limit. 336 // Get stack trace limit.
337 Handle<Object> error = Object::GetProperty( 337 Handle<Object> error = Object::GetProperty(
338 this, js_builtins_object(), "$Error").ToHandleChecked(); 338 this, js_builtins_object(), "$Error").ToHandleChecked();
339 if (!error->IsJSObject()) return factory()->undefined_value(); 339 if (!error->IsJSObject()) return factory()->undefined_value();
340 340
341 Handle<String> stackTraceLimit = 341 Handle<String> stackTraceLimit =
342 factory()->InternalizeUtf8String("stackTraceLimit"); 342 factory()->InternalizeUtf8String("stackTraceLimit");
343 DCHECK(!stackTraceLimit.is_null()); 343 DCHECK(!stackTraceLimit.is_null());
344 Handle<Object> stack_trace_limit = 344 Handle<Object> stack_trace_limit = JSReceiver::GetDataProperty(
345 JSObject::GetDataProperty(Handle<JSObject>::cast(error), 345 Handle<JSObject>::cast(error), stackTraceLimit);
346 stackTraceLimit);
347 if (!stack_trace_limit->IsNumber()) return factory()->undefined_value(); 346 if (!stack_trace_limit->IsNumber()) return factory()->undefined_value();
348 int limit = FastD2IChecked(stack_trace_limit->Number()); 347 int limit = FastD2IChecked(stack_trace_limit->Number());
349 limit = Max(limit, 0); // Ensure that limit is not negative. 348 limit = Max(limit, 0); // Ensure that limit is not negative.
350 349
351 int initial_size = Min(limit, 10); 350 int initial_size = Min(limit, 10);
352 Handle<FixedArray> elements = 351 Handle<FixedArray> elements =
353 factory()->NewFixedArrayWithHoles(initial_size * 4 + 1); 352 factory()->NewFixedArrayWithHoles(initial_size * 4 + 1);
354 353
355 // If the caller parameter is a function we skip frames until we're 354 // If the caller parameter is a function we skip frames until we're
356 // under it before starting to collect. 355 // under it before starting to collect.
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 RETURN_ON_EXCEPTION( 438 RETURN_ON_EXCEPTION(
440 this, JSObject::SetProperty(error_object, key, stack_trace, STRICT), 439 this, JSObject::SetProperty(error_object, key, stack_trace, STRICT),
441 JSObject); 440 JSObject);
442 return error_object; 441 return error_object;
443 } 442 }
444 443
445 444
446 Handle<JSArray> Isolate::GetDetailedStackTrace(Handle<JSObject> error_object) { 445 Handle<JSArray> Isolate::GetDetailedStackTrace(Handle<JSObject> error_object) {
447 Handle<Name> key_detailed = factory()->detailed_stack_trace_symbol(); 446 Handle<Name> key_detailed = factory()->detailed_stack_trace_symbol();
448 Handle<Object> stack_trace = 447 Handle<Object> stack_trace =
449 JSObject::GetDataProperty(error_object, key_detailed); 448 JSReceiver::GetDataProperty(error_object, key_detailed);
450 if (stack_trace->IsJSArray()) return Handle<JSArray>::cast(stack_trace); 449 if (stack_trace->IsJSArray()) return Handle<JSArray>::cast(stack_trace);
451 450
452 if (!capture_stack_trace_for_uncaught_exceptions_) return Handle<JSArray>(); 451 if (!capture_stack_trace_for_uncaught_exceptions_) return Handle<JSArray>();
453 452
454 // Try to get details from simple stack trace. 453 // Try to get details from simple stack trace.
455 Handle<JSArray> detailed_stack_trace = 454 Handle<JSArray> detailed_stack_trace =
456 GetDetailedFromSimpleStackTrace(error_object); 455 GetDetailedFromSimpleStackTrace(error_object);
457 if (!detailed_stack_trace.is_null()) { 456 if (!detailed_stack_trace.is_null()) {
458 // Save the detailed stack since the simple one might be withdrawn later. 457 // Save the detailed stack since the simple one might be withdrawn later.
459 JSObject::SetProperty(error_object, key_detailed, detailed_stack_trace, 458 JSObject::SetProperty(error_object, key_detailed, detailed_stack_trace,
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 Code* code = Code::cast(maybe_code); 592 Code* code = Code::cast(maybe_code);
594 Address pc = code->address() + Smi::cast(elements->get(index + 3))->value(); 593 Address pc = code->address() + Smi::cast(elements->get(index + 3))->value();
595 return code->SourcePosition(pc); 594 return code->SourcePosition(pc);
596 } 595 }
597 } 596 }
598 597
599 598
600 Handle<JSArray> Isolate::GetDetailedFromSimpleStackTrace( 599 Handle<JSArray> Isolate::GetDetailedFromSimpleStackTrace(
601 Handle<JSObject> error_object) { 600 Handle<JSObject> error_object) {
602 Handle<Name> key = factory()->stack_trace_symbol(); 601 Handle<Name> key = factory()->stack_trace_symbol();
603 Handle<Object> property = JSObject::GetDataProperty(error_object, key); 602 Handle<Object> property = JSReceiver::GetDataProperty(error_object, key);
604 if (!property->IsJSArray()) return Handle<JSArray>(); 603 if (!property->IsJSArray()) return Handle<JSArray>();
605 Handle<JSArray> simple_stack_trace = Handle<JSArray>::cast(property); 604 Handle<JSArray> simple_stack_trace = Handle<JSArray>::cast(property);
606 605
607 CaptureStackTraceHelper helper(this, 606 CaptureStackTraceHelper helper(this,
608 stack_trace_for_uncaught_exceptions_options_); 607 stack_trace_for_uncaught_exceptions_options_);
609 608
610 int frames_seen = 0; 609 int frames_seen = 0;
611 Handle<FixedArray> elements(FixedArray::cast(simple_stack_trace->elements())); 610 Handle<FixedArray> elements(FixedArray::cast(simple_stack_trace->elements()));
612 int elements_limit = Smi::cast(simple_stack_trace->length())->value(); 611 int elements_limit = Smi::cast(simple_stack_trace->length())->value();
613 612
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
1265 } 1264 }
1266 } 1265 }
1267 } 1266 }
1268 1267
1269 1268
1270 bool Isolate::ComputeLocationFromException(MessageLocation* target, 1269 bool Isolate::ComputeLocationFromException(MessageLocation* target,
1271 Handle<Object> exception) { 1270 Handle<Object> exception) {
1272 if (!exception->IsJSObject()) return false; 1271 if (!exception->IsJSObject()) return false;
1273 1272
1274 Handle<Name> start_pos_symbol = factory()->error_start_pos_symbol(); 1273 Handle<Name> start_pos_symbol = factory()->error_start_pos_symbol();
1275 Handle<Object> start_pos = JSObject::GetDataProperty( 1274 Handle<Object> start_pos = JSReceiver::GetDataProperty(
1276 Handle<JSObject>::cast(exception), start_pos_symbol); 1275 Handle<JSObject>::cast(exception), start_pos_symbol);
1277 if (!start_pos->IsSmi()) return false; 1276 if (!start_pos->IsSmi()) return false;
1278 int start_pos_value = Handle<Smi>::cast(start_pos)->value(); 1277 int start_pos_value = Handle<Smi>::cast(start_pos)->value();
1279 1278
1280 Handle<Name> end_pos_symbol = factory()->error_end_pos_symbol(); 1279 Handle<Name> end_pos_symbol = factory()->error_end_pos_symbol();
1281 Handle<Object> end_pos = JSObject::GetDataProperty( 1280 Handle<Object> end_pos = JSReceiver::GetDataProperty(
1282 Handle<JSObject>::cast(exception), end_pos_symbol); 1281 Handle<JSObject>::cast(exception), end_pos_symbol);
1283 if (!end_pos->IsSmi()) return false; 1282 if (!end_pos->IsSmi()) return false;
1284 int end_pos_value = Handle<Smi>::cast(end_pos)->value(); 1283 int end_pos_value = Handle<Smi>::cast(end_pos)->value();
1285 1284
1286 Handle<Name> script_symbol = factory()->error_script_symbol(); 1285 Handle<Name> script_symbol = factory()->error_script_symbol();
1287 Handle<Object> script = JSObject::GetDataProperty( 1286 Handle<Object> script = JSReceiver::GetDataProperty(
1288 Handle<JSObject>::cast(exception), script_symbol); 1287 Handle<JSObject>::cast(exception), script_symbol);
1289 if (!script->IsScript()) return false; 1288 if (!script->IsScript()) return false;
1290 1289
1291 Handle<Script> cast_script(Script::cast(*script)); 1290 Handle<Script> cast_script(Script::cast(*script));
1292 *target = MessageLocation(cast_script, start_pos_value, end_pos_value); 1291 *target = MessageLocation(cast_script, start_pos_value, end_pos_value);
1293 return true; 1292 return true;
1294 } 1293 }
1295 1294
1296 1295
1297 bool Isolate::ComputeLocationFromStackTrace(MessageLocation* target, 1296 bool Isolate::ComputeLocationFromStackTrace(MessageLocation* target,
1298 Handle<Object> exception) { 1297 Handle<Object> exception) {
1299 *target = MessageLocation(Handle<Script>(heap_.empty_script()), -1, -1); 1298 *target = MessageLocation(Handle<Script>(heap_.empty_script()), -1, -1);
1300 1299
1301 if (!exception->IsJSObject()) return false; 1300 if (!exception->IsJSObject()) return false;
1302 Handle<Name> key = factory()->stack_trace_symbol(); 1301 Handle<Name> key = factory()->stack_trace_symbol();
1303 Handle<Object> property = 1302 Handle<Object> property =
1304 JSObject::GetDataProperty(Handle<JSObject>::cast(exception), key); 1303 JSReceiver::GetDataProperty(Handle<JSObject>::cast(exception), key);
1305 if (!property->IsJSArray()) return false; 1304 if (!property->IsJSArray()) return false;
1306 Handle<JSArray> simple_stack_trace = Handle<JSArray>::cast(property); 1305 Handle<JSArray> simple_stack_trace = Handle<JSArray>::cast(property);
1307 1306
1308 Handle<FixedArray> elements(FixedArray::cast(simple_stack_trace->elements())); 1307 Handle<FixedArray> elements(FixedArray::cast(simple_stack_trace->elements()));
1309 int elements_limit = Smi::cast(simple_stack_trace->length())->value(); 1308 int elements_limit = Smi::cast(simple_stack_trace->length())->value();
1310 1309
1311 for (int i = 1; i < elements_limit; i += 4) { 1310 for (int i = 1; i < elements_limit; i += 4) {
1312 Handle<JSFunction> fun = 1311 Handle<JSFunction> fun =
1313 handle(JSFunction::cast(elements->get(i + 1)), this); 1312 handle(JSFunction::cast(elements->get(i + 1)), this);
1314 if (fun->IsFromNativeScript()) continue; 1313 if (fun->IsFromNativeScript()) continue;
(...skipping 1467 matching lines...) Expand 10 before | Expand all | Expand 10 after
2782 if (prev_ && prev_->Intercept(flag)) return true; 2781 if (prev_ && prev_->Intercept(flag)) return true;
2783 // Then check whether this scope intercepts. 2782 // Then check whether this scope intercepts.
2784 if ((flag & intercept_mask_)) { 2783 if ((flag & intercept_mask_)) {
2785 intercepted_flags_ |= flag; 2784 intercepted_flags_ |= flag;
2786 return true; 2785 return true;
2787 } 2786 }
2788 return false; 2787 return false;
2789 } 2788 }
2790 2789
2791 } } // namespace v8::internal 2790 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ic/ic.cc ('k') | src/json.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698