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

Side by Side Diff: src/isolate.cc

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