OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 incomplete_message->OutputToStdOut(); | 367 incomplete_message->OutputToStdOut(); |
368 return Factory::empty_symbol(); | 368 return Factory::empty_symbol(); |
369 } else { | 369 } else { |
370 OS::Abort(); | 370 OS::Abort(); |
371 // Unreachable | 371 // Unreachable |
372 return Factory::empty_symbol(); | 372 return Factory::empty_symbol(); |
373 } | 373 } |
374 } | 374 } |
375 | 375 |
376 | 376 |
377 static void SetLocalProperty(Handle<JSObject> object, | |
378 Handle<String> key, | |
379 Handle<Object> value) { | |
380 // We set properties on freshly allocated JS object, nothing | |
381 // should fail except for OOM which is handled by | |
382 // SetLocalPropertyIgnoreAttributes. | |
383 ASSERT(!Top::has_pending_exception()); | |
384 CHECK(!SetLocalPropertyIgnoreAttributes(object, key, value, NONE).is_null()); | |
385 CHECK(!Top::has_pending_exception()); | |
386 } | |
387 | |
388 | |
389 Handle<JSArray> Top::CaptureCurrentStackTrace( | 377 Handle<JSArray> Top::CaptureCurrentStackTrace( |
390 int frame_limit, StackTrace::StackTraceOptions options) { | 378 int frame_limit, StackTrace::StackTraceOptions options) { |
391 // Ensure no negative values. | 379 // Ensure no negative values. |
392 int limit = Max(frame_limit, 0); | 380 int limit = Max(frame_limit, 0); |
393 Handle<JSArray> stack_trace = Factory::NewJSArray(frame_limit); | 381 Handle<JSArray> stack_trace = Factory::NewJSArray(frame_limit); |
394 | 382 |
395 Handle<String> column_key = Factory::LookupAsciiSymbol("column"); | 383 Handle<String> column_key = Factory::LookupAsciiSymbol("column"); |
396 Handle<String> line_key = Factory::LookupAsciiSymbol("lineNumber"); | 384 Handle<String> line_key = Factory::LookupAsciiSymbol("lineNumber"); |
397 Handle<String> script_key = Factory::LookupAsciiSymbol("scriptName"); | 385 Handle<String> script_key = Factory::LookupAsciiSymbol("scriptName"); |
398 Handle<String> name_or_source_url_key = | 386 Handle<String> name_or_source_url_key = |
(...skipping 27 matching lines...) Expand all Loading... |
426 if (options & StackTrace::kColumnOffset && relative_line_number >= 0) { | 414 if (options & StackTrace::kColumnOffset && relative_line_number >= 0) { |
427 Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends())); | 415 Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends())); |
428 int start = (relative_line_number == 0) ? 0 : | 416 int start = (relative_line_number == 0) ? 0 : |
429 Smi::cast(line_ends->get(relative_line_number - 1))->value() + 1; | 417 Smi::cast(line_ends->get(relative_line_number - 1))->value() + 1; |
430 int column_offset = position - start; | 418 int column_offset = position - start; |
431 if (relative_line_number == 0) { | 419 if (relative_line_number == 0) { |
432 // For the case where the code is on the same line as the script | 420 // For the case where the code is on the same line as the script |
433 // tag. | 421 // tag. |
434 column_offset += script->column_offset()->value(); | 422 column_offset += script->column_offset()->value(); |
435 } | 423 } |
436 SetLocalProperty(stackFrame, column_key, | 424 SetLocalPropertyNoThrow(stackFrame, column_key, |
437 Handle<Smi>(Smi::FromInt(column_offset + 1))); | 425 Handle<Smi>(Smi::FromInt(column_offset + 1))); |
438 } | 426 } |
439 SetLocalProperty(stackFrame, line_key, | 427 SetLocalPropertyNoThrow(stackFrame, line_key, |
440 Handle<Smi>(Smi::FromInt(line_number + 1))); | 428 Handle<Smi>(Smi::FromInt(line_number + 1))); |
441 } | 429 } |
442 | 430 |
443 if (options & StackTrace::kScriptName) { | 431 if (options & StackTrace::kScriptName) { |
444 Handle<Object> script_name(script->name()); | 432 Handle<Object> script_name(script->name()); |
445 SetLocalProperty(stackFrame, script_key, script_name); | 433 SetLocalPropertyNoThrow(stackFrame, script_key, script_name); |
446 } | 434 } |
447 | 435 |
448 if (options & StackTrace::kScriptNameOrSourceURL) { | 436 if (options & StackTrace::kScriptNameOrSourceURL) { |
449 Handle<Object> script_name(script->name()); | 437 Handle<Object> script_name(script->name()); |
450 Handle<JSValue> script_wrapper = GetScriptWrapper(script); | 438 Handle<JSValue> script_wrapper = GetScriptWrapper(script); |
451 Handle<Object> property = GetProperty(script_wrapper, | 439 Handle<Object> property = GetProperty(script_wrapper, |
452 name_or_source_url_key); | 440 name_or_source_url_key); |
453 ASSERT(property->IsJSFunction()); | 441 ASSERT(property->IsJSFunction()); |
454 Handle<JSFunction> method = Handle<JSFunction>::cast(property); | 442 Handle<JSFunction> method = Handle<JSFunction>::cast(property); |
455 bool caught_exception; | 443 bool caught_exception; |
456 Handle<Object> result = Execution::TryCall(method, script_wrapper, 0, | 444 Handle<Object> result = Execution::TryCall(method, script_wrapper, 0, |
457 NULL, &caught_exception); | 445 NULL, &caught_exception); |
458 if (caught_exception) { | 446 if (caught_exception) { |
459 result = Factory::undefined_value(); | 447 result = Factory::undefined_value(); |
460 } | 448 } |
461 SetLocalProperty(stackFrame, script_name_or_source_url_key, result); | 449 SetLocalPropertyNoThrow(stackFrame, script_name_or_source_url_key, |
| 450 result); |
462 } | 451 } |
463 | 452 |
464 if (options & StackTrace::kFunctionName) { | 453 if (options & StackTrace::kFunctionName) { |
465 Handle<Object> fun_name(fun->shared()->name()); | 454 Handle<Object> fun_name(fun->shared()->name()); |
466 if (fun_name->ToBoolean()->IsFalse()) { | 455 if (fun_name->ToBoolean()->IsFalse()) { |
467 fun_name = Handle<Object>(fun->shared()->inferred_name()); | 456 fun_name = Handle<Object>(fun->shared()->inferred_name()); |
468 } | 457 } |
469 SetLocalProperty(stackFrame, function_key, fun_name); | 458 SetLocalPropertyNoThrow(stackFrame, function_key, fun_name); |
470 } | 459 } |
471 | 460 |
472 if (options & StackTrace::kIsEval) { | 461 if (options & StackTrace::kIsEval) { |
473 int type = Smi::cast(script->compilation_type())->value(); | 462 int type = Smi::cast(script->compilation_type())->value(); |
474 Handle<Object> is_eval = (type == Script::COMPILATION_TYPE_EVAL) ? | 463 Handle<Object> is_eval = (type == Script::COMPILATION_TYPE_EVAL) ? |
475 Factory::true_value() : Factory::false_value(); | 464 Factory::true_value() : Factory::false_value(); |
476 SetLocalProperty(stackFrame, eval_key, is_eval); | 465 SetLocalPropertyNoThrow(stackFrame, eval_key, is_eval); |
477 } | 466 } |
478 | 467 |
479 if (options & StackTrace::kIsConstructor) { | 468 if (options & StackTrace::kIsConstructor) { |
480 Handle<Object> is_constructor = (frames[i].is_constructor()) ? | 469 Handle<Object> is_constructor = (frames[i].is_constructor()) ? |
481 Factory::true_value() : Factory::false_value(); | 470 Factory::true_value() : Factory::false_value(); |
482 SetLocalProperty(stackFrame, constructor_key, is_constructor); | 471 SetLocalPropertyNoThrow(stackFrame, constructor_key, is_constructor); |
483 } | 472 } |
484 | 473 |
485 FixedArray::cast(stack_trace->elements())->set(frames_seen, *stackFrame); | 474 FixedArray::cast(stack_trace->elements())->set(frames_seen, *stackFrame); |
486 frames_seen++; | 475 frames_seen++; |
487 } | 476 } |
488 it.Advance(); | 477 it.Advance(); |
489 } | 478 } |
490 | 479 |
491 stack_trace->set_length(Smi::FromInt(frames_seen)); | 480 stack_trace->set_length(Smi::FromInt(frames_seen)); |
492 return stack_trace; | 481 return stack_trace; |
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1109 #ifdef V8_TARGET_ARCH_ARM | 1098 #ifdef V8_TARGET_ARCH_ARM |
1110 thread_local_.simulator_ = Simulator::current(); | 1099 thread_local_.simulator_ = Simulator::current(); |
1111 #elif V8_TARGET_ARCH_MIPS | 1100 #elif V8_TARGET_ARCH_MIPS |
1112 thread_local_.simulator_ = assembler::mips::Simulator::current(); | 1101 thread_local_.simulator_ = assembler::mips::Simulator::current(); |
1113 #endif | 1102 #endif |
1114 #endif | 1103 #endif |
1115 return from + sizeof(thread_local_); | 1104 return from + sizeof(thread_local_); |
1116 } | 1105 } |
1117 | 1106 |
1118 } } // namespace v8::internal | 1107 } } // namespace v8::internal |
OLD | NEW |