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

Side by Side Diff: src/isolate.cc

Issue 9227007: Version 3.8.6 (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 8 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « src/isolate.h ('k') | src/json-parser.h » ('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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 StackTraceFrameIterator it(this); 563 StackTraceFrameIterator it(this);
564 int frames_seen = 0; 564 int frames_seen = 0;
565 while (!it.done() && (frames_seen < limit)) { 565 while (!it.done() && (frames_seen < limit)) {
566 JavaScriptFrame* frame = it.frame(); 566 JavaScriptFrame* frame = it.frame();
567 // Set initial size to the maximum inlining level + 1 for the outermost 567 // Set initial size to the maximum inlining level + 1 for the outermost
568 // function. 568 // function.
569 List<FrameSummary> frames(Compiler::kMaxInliningLevels + 1); 569 List<FrameSummary> frames(Compiler::kMaxInliningLevels + 1);
570 frame->Summarize(&frames); 570 frame->Summarize(&frames);
571 for (int i = frames.length() - 1; i >= 0 && frames_seen < limit; i--) { 571 for (int i = frames.length() - 1; i >= 0 && frames_seen < limit; i--) {
572 // Create a JSObject to hold the information for the StackFrame. 572 // Create a JSObject to hold the information for the StackFrame.
573 Handle<JSObject> stackFrame = factory()->NewJSObject(object_function()); 573 Handle<JSObject> stack_frame = factory()->NewJSObject(object_function());
574 574
575 Handle<JSFunction> fun = frames[i].function(); 575 Handle<JSFunction> fun = frames[i].function();
576 Handle<Script> script(Script::cast(fun->shared()->script())); 576 Handle<Script> script(Script::cast(fun->shared()->script()));
577 577
578 if (options & StackTrace::kLineNumber) { 578 if (options & StackTrace::kLineNumber) {
579 int script_line_offset = script->line_offset()->value(); 579 int script_line_offset = script->line_offset()->value();
580 int position = frames[i].code()->SourcePosition(frames[i].pc()); 580 int position = frames[i].code()->SourcePosition(frames[i].pc());
581 int line_number = GetScriptLineNumber(script, position); 581 int line_number = GetScriptLineNumber(script, position);
582 // line_number is already shifted by the script_line_offset. 582 // line_number is already shifted by the script_line_offset.
583 int relative_line_number = line_number - script_line_offset; 583 int relative_line_number = line_number - script_line_offset;
584 if (options & StackTrace::kColumnOffset && relative_line_number >= 0) { 584 if (options & StackTrace::kColumnOffset && relative_line_number >= 0) {
585 Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends())); 585 Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends()));
586 int start = (relative_line_number == 0) ? 0 : 586 int start = (relative_line_number == 0) ? 0 :
587 Smi::cast(line_ends->get(relative_line_number - 1))->value() + 1; 587 Smi::cast(line_ends->get(relative_line_number - 1))->value() + 1;
588 int column_offset = position - start; 588 int column_offset = position - start;
589 if (relative_line_number == 0) { 589 if (relative_line_number == 0) {
590 // For the case where the code is on the same line as the script 590 // For the case where the code is on the same line as the script
591 // tag. 591 // tag.
592 column_offset += script->column_offset()->value(); 592 column_offset += script->column_offset()->value();
593 } 593 }
594 SetLocalPropertyNoThrow(stackFrame, column_key, 594 CHECK_NOT_EMPTY_HANDLE(
595 Handle<Smi>(Smi::FromInt(column_offset + 1))); 595 this,
596 JSObject::SetLocalPropertyIgnoreAttributes(
597 stack_frame, column_key,
598 Handle<Smi>(Smi::FromInt(column_offset + 1)), NONE));
596 } 599 }
597 SetLocalPropertyNoThrow(stackFrame, line_key, 600 CHECK_NOT_EMPTY_HANDLE(
598 Handle<Smi>(Smi::FromInt(line_number + 1))); 601 this,
602 JSObject::SetLocalPropertyIgnoreAttributes(
603 stack_frame, line_key,
604 Handle<Smi>(Smi::FromInt(line_number + 1)), NONE));
599 } 605 }
600 606
601 if (options & StackTrace::kScriptName) { 607 if (options & StackTrace::kScriptName) {
602 Handle<Object> script_name(script->name(), this); 608 Handle<Object> script_name(script->name(), this);
603 SetLocalPropertyNoThrow(stackFrame, script_key, script_name); 609 CHECK_NOT_EMPTY_HANDLE(this,
610 JSObject::SetLocalPropertyIgnoreAttributes(
611 stack_frame, script_key, script_name, NONE));
604 } 612 }
605 613
606 if (options & StackTrace::kScriptNameOrSourceURL) { 614 if (options & StackTrace::kScriptNameOrSourceURL) {
607 Handle<Object> script_name(script->name(), this); 615 Handle<Object> script_name(script->name(), this);
608 Handle<JSValue> script_wrapper = GetScriptWrapper(script); 616 Handle<JSValue> script_wrapper = GetScriptWrapper(script);
609 Handle<Object> property = GetProperty(script_wrapper, 617 Handle<Object> property = GetProperty(script_wrapper,
610 name_or_source_url_key); 618 name_or_source_url_key);
611 ASSERT(property->IsJSFunction()); 619 ASSERT(property->IsJSFunction());
612 Handle<JSFunction> method = Handle<JSFunction>::cast(property); 620 Handle<JSFunction> method = Handle<JSFunction>::cast(property);
613 bool caught_exception; 621 bool caught_exception;
614 Handle<Object> result = Execution::TryCall(method, script_wrapper, 0, 622 Handle<Object> result = Execution::TryCall(method, script_wrapper, 0,
615 NULL, &caught_exception); 623 NULL, &caught_exception);
616 if (caught_exception) { 624 if (caught_exception) {
617 result = factory()->undefined_value(); 625 result = factory()->undefined_value();
618 } 626 }
619 SetLocalPropertyNoThrow(stackFrame, script_name_or_source_url_key, 627 CHECK_NOT_EMPTY_HANDLE(this,
620 result); 628 JSObject::SetLocalPropertyIgnoreAttributes(
629 stack_frame, script_name_or_source_url_key,
630 result, NONE));
621 } 631 }
622 632
623 if (options & StackTrace::kFunctionName) { 633 if (options & StackTrace::kFunctionName) {
624 Handle<Object> fun_name(fun->shared()->name(), this); 634 Handle<Object> fun_name(fun->shared()->name(), this);
625 if (fun_name->ToBoolean()->IsFalse()) { 635 if (fun_name->ToBoolean()->IsFalse()) {
626 fun_name = Handle<Object>(fun->shared()->inferred_name(), this); 636 fun_name = Handle<Object>(fun->shared()->inferred_name(), this);
627 } 637 }
628 SetLocalPropertyNoThrow(stackFrame, function_key, fun_name); 638 CHECK_NOT_EMPTY_HANDLE(this,
639 JSObject::SetLocalPropertyIgnoreAttributes(
640 stack_frame, function_key, fun_name, NONE));
629 } 641 }
630 642
631 if (options & StackTrace::kIsEval) { 643 if (options & StackTrace::kIsEval) {
632 int type = Smi::cast(script->compilation_type())->value(); 644 int type = Smi::cast(script->compilation_type())->value();
633 Handle<Object> is_eval = (type == Script::COMPILATION_TYPE_EVAL) ? 645 Handle<Object> is_eval = (type == Script::COMPILATION_TYPE_EVAL) ?
634 factory()->true_value() : factory()->false_value(); 646 factory()->true_value() : factory()->false_value();
635 SetLocalPropertyNoThrow(stackFrame, eval_key, is_eval); 647 CHECK_NOT_EMPTY_HANDLE(this,
648 JSObject::SetLocalPropertyIgnoreAttributes(
649 stack_frame, eval_key, is_eval, NONE));
636 } 650 }
637 651
638 if (options & StackTrace::kIsConstructor) { 652 if (options & StackTrace::kIsConstructor) {
639 Handle<Object> is_constructor = (frames[i].is_constructor()) ? 653 Handle<Object> is_constructor = (frames[i].is_constructor()) ?
640 factory()->true_value() : factory()->false_value(); 654 factory()->true_value() : factory()->false_value();
641 SetLocalPropertyNoThrow(stackFrame, constructor_key, is_constructor); 655 CHECK_NOT_EMPTY_HANDLE(this,
656 JSObject::SetLocalPropertyIgnoreAttributes(
657 stack_frame, constructor_key,
658 is_constructor, NONE));
642 } 659 }
643 660
644 FixedArray::cast(stack_trace->elements())->set(frames_seen, *stackFrame); 661 FixedArray::cast(stack_trace->elements())->set(frames_seen, *stack_frame);
645 frames_seen++; 662 frames_seen++;
646 } 663 }
647 it.Advance(); 664 it.Advance();
648 } 665 }
649 666
650 stack_trace->set_length(Smi::FromInt(frames_seen)); 667 stack_trace->set_length(Smi::FromInt(frames_seen));
651 return stack_trace; 668 return stack_trace;
652 } 669 }
653 670
654 671
(...skipping 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after
1727 inner_pointer_to_code_cache_ = new InnerPointerToCodeCache(this); 1744 inner_pointer_to_code_cache_ = new InnerPointerToCodeCache(this);
1728 write_input_buffer_ = new StringInputBuffer(); 1745 write_input_buffer_ = new StringInputBuffer();
1729 global_handles_ = new GlobalHandles(this); 1746 global_handles_ = new GlobalHandles(this);
1730 bootstrapper_ = new Bootstrapper(); 1747 bootstrapper_ = new Bootstrapper();
1731 handle_scope_implementer_ = new HandleScopeImplementer(this); 1748 handle_scope_implementer_ = new HandleScopeImplementer(this);
1732 stub_cache_ = new StubCache(this); 1749 stub_cache_ = new StubCache(this);
1733 regexp_stack_ = new RegExpStack(); 1750 regexp_stack_ = new RegExpStack();
1734 regexp_stack_->isolate_ = this; 1751 regexp_stack_->isolate_ = this;
1735 1752
1736 // Enable logging before setting up the heap 1753 // Enable logging before setting up the heap
1737 logger_->Setup(); 1754 logger_->SetUp();
1738 1755
1739 CpuProfiler::Setup(); 1756 CpuProfiler::SetUp();
1740 HeapProfiler::Setup(); 1757 HeapProfiler::SetUp();
1741 1758
1742 // Initialize other runtime facilities 1759 // Initialize other runtime facilities
1743 #if defined(USE_SIMULATOR) 1760 #if defined(USE_SIMULATOR)
1744 #if defined(V8_TARGET_ARCH_ARM) || defined(V8_TARGET_ARCH_MIPS) 1761 #if defined(V8_TARGET_ARCH_ARM) || defined(V8_TARGET_ARCH_MIPS)
1745 Simulator::Initialize(this); 1762 Simulator::Initialize(this);
1746 #endif 1763 #endif
1747 #endif 1764 #endif
1748 1765
1749 { // NOLINT 1766 { // NOLINT
1750 // Ensure that the thread has a valid stack guard. The v8::Locker object 1767 // Ensure that the thread has a valid stack guard. The v8::Locker object
1751 // will ensure this too, but we don't have to use lockers if we are only 1768 // will ensure this too, but we don't have to use lockers if we are only
1752 // using one thread. 1769 // using one thread.
1753 ExecutionAccess lock(this); 1770 ExecutionAccess lock(this);
1754 stack_guard_.InitThread(lock); 1771 stack_guard_.InitThread(lock);
1755 } 1772 }
1756 1773
1757 // Setup the object heap. 1774 // SetUp the object heap.
1758 const bool create_heap_objects = (des == NULL); 1775 const bool create_heap_objects = (des == NULL);
1759 ASSERT(!heap_.HasBeenSetup()); 1776 ASSERT(!heap_.HasBeenSetUp());
1760 if (!heap_.Setup(create_heap_objects)) { 1777 if (!heap_.SetUp(create_heap_objects)) {
1761 V8::SetFatalError(); 1778 V8::SetFatalError();
1762 return false; 1779 return false;
1763 } 1780 }
1764 1781
1765 InitializeThreadLocal(); 1782 InitializeThreadLocal();
1766 1783
1767 bootstrapper_->Initialize(create_heap_objects); 1784 bootstrapper_->Initialize(create_heap_objects);
1768 builtins_.Setup(create_heap_objects); 1785 builtins_.SetUp(create_heap_objects);
1769 1786
1770 // Only preallocate on the first initialization. 1787 // Only preallocate on the first initialization.
1771 if (FLAG_preallocate_message_memory && preallocated_message_space_ == NULL) { 1788 if (FLAG_preallocate_message_memory && preallocated_message_space_ == NULL) {
1772 // Start the thread which will set aside some memory. 1789 // Start the thread which will set aside some memory.
1773 PreallocatedMemoryThreadStart(); 1790 PreallocatedMemoryThreadStart();
1774 preallocated_message_space_ = 1791 preallocated_message_space_ =
1775 new NoAllocationStringAllocator( 1792 new NoAllocationStringAllocator(
1776 preallocated_memory_thread_->data(), 1793 preallocated_memory_thread_->data(),
1777 preallocated_memory_thread_->length()); 1794 preallocated_memory_thread_->length());
1778 PreallocatedStorageInit(preallocated_memory_thread_->length() / 4); 1795 PreallocatedStorageInit(preallocated_memory_thread_->length() / 4);
1779 } 1796 }
1780 1797
1781 if (FLAG_preemption) { 1798 if (FLAG_preemption) {
1782 v8::Locker locker; 1799 v8::Locker locker;
1783 v8::Locker::StartPreemption(100); 1800 v8::Locker::StartPreemption(100);
1784 } 1801 }
1785 1802
1786 #ifdef ENABLE_DEBUGGER_SUPPORT 1803 #ifdef ENABLE_DEBUGGER_SUPPORT
1787 debug_->Setup(create_heap_objects); 1804 debug_->SetUp(create_heap_objects);
1788 #endif 1805 #endif
1789 stub_cache_->Initialize(create_heap_objects); 1806 stub_cache_->Initialize(create_heap_objects);
1790 1807
1791 // If we are deserializing, read the state into the now-empty heap. 1808 // If we are deserializing, read the state into the now-empty heap.
1792 if (des != NULL) { 1809 if (des != NULL) {
1793 des->Deserialize(); 1810 des->Deserialize();
1794 stub_cache_->Initialize(true); 1811 stub_cache_->Initialize(true);
1795 } 1812 }
1796 1813
1797 // Finish initialization of ThreadLocal after deserialization is done. 1814 // Finish initialization of ThreadLocal after deserialization is done.
1798 clear_pending_exception(); 1815 clear_pending_exception();
1799 clear_pending_message(); 1816 clear_pending_message();
1800 clear_scheduled_exception(); 1817 clear_scheduled_exception();
1801 1818
1802 // Deserializing may put strange things in the root array's copy of the 1819 // Deserializing may put strange things in the root array's copy of the
1803 // stack guard. 1820 // stack guard.
1804 heap_.SetStackLimits(); 1821 heap_.SetStackLimits();
1805 1822
1806 deoptimizer_data_ = new DeoptimizerData; 1823 deoptimizer_data_ = new DeoptimizerData;
1807 runtime_profiler_ = new RuntimeProfiler(this); 1824 runtime_profiler_ = new RuntimeProfiler(this);
1808 runtime_profiler_->Setup(); 1825 runtime_profiler_->SetUp();
1809 1826
1810 // If we are deserializing, log non-function code objects and compiled 1827 // If we are deserializing, log non-function code objects and compiled
1811 // functions found in the snapshot. 1828 // functions found in the snapshot.
1812 if (des != NULL && (FLAG_log_code || FLAG_ll_prof)) { 1829 if (des != NULL && (FLAG_log_code || FLAG_ll_prof)) {
1813 HandleScope scope; 1830 HandleScope scope;
1814 LOG(this, LogCodeObjects()); 1831 LOG(this, LogCodeObjects());
1815 LOG(this, LogCompiledFunctions()); 1832 LOG(this, LogCompiledFunctions());
1816 } 1833 }
1817 1834
1818 state_ = INITIALIZED; 1835 state_ = INITIALIZED;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1901 1918
1902 #ifdef DEBUG 1919 #ifdef DEBUG
1903 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ 1920 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \
1904 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); 1921 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_);
1905 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) 1922 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET)
1906 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) 1923 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET)
1907 #undef ISOLATE_FIELD_OFFSET 1924 #undef ISOLATE_FIELD_OFFSET
1908 #endif 1925 #endif
1909 1926
1910 } } // namespace v8::internal 1927 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/isolate.h ('k') | src/json-parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698