| OLD | NEW |
| 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 "src/isolate.h" | 5 #include "src/isolate.h" |
| 6 | 6 |
| 7 #include <stdlib.h> | 7 #include <stdlib.h> |
| 8 | 8 |
| 9 #include <fstream> // NOLINT(readability/streams) | 9 #include <fstream> // NOLINT(readability/streams) |
| 10 #include <sstream> | 10 #include <sstream> |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 helper.CountSloppyFrames(*fun); | 508 helper.CountSloppyFrames(*fun); |
| 509 | 509 |
| 510 Handle<Code> code = handle(exit_frame->LookupCode(), this); | 510 Handle<Code> code = handle(exit_frame->LookupCode(), this); |
| 511 int offset = | 511 int offset = |
| 512 static_cast<int>(exit_frame->pc() - code->instruction_start()); | 512 static_cast<int>(exit_frame->pc() - code->instruction_start()); |
| 513 | 513 |
| 514 // In order to help CallSite::IsConstructor detect builtin constructors, | 514 // In order to help CallSite::IsConstructor detect builtin constructors, |
| 515 // we reuse the receiver field to pass along a special symbol. | 515 // we reuse the receiver field to pass along a special symbol. |
| 516 Handle<Object> recv; | 516 Handle<Object> recv; |
| 517 if (exit_frame->IsConstructor()) { | 517 if (exit_frame->IsConstructor()) { |
| 518 recv = handle(heap()->call_site_constructor_symbol(), this); | 518 recv = factory()->call_site_constructor_symbol(); |
| 519 } else { | 519 } else { |
| 520 recv = handle(exit_frame->receiver(), this); | 520 recv = handle(exit_frame->receiver(), this); |
| 521 } | 521 } |
| 522 | 522 |
| 523 elements = MaybeGrow(this, elements, cursor, cursor + 4); | 523 elements = MaybeGrow(this, elements, cursor, cursor + 4); |
| 524 elements->set(cursor++, *recv); | 524 elements->set(cursor++, *recv); |
| 525 elements->set(cursor++, *fun); | 525 elements->set(cursor++, *fun); |
| 526 elements->set(cursor++, *code); | 526 elements->set(cursor++, *code); |
| 527 elements->set(cursor++, Smi::FromInt(offset)); | 527 elements->set(cursor++, Smi::FromInt(offset)); |
| 528 frames_seen++; | 528 frames_seen++; |
| 529 } break; | 529 } break; |
| 530 | 530 |
| 531 case StackFrame::WASM: { | 531 case StackFrame::WASM: { |
| 532 WasmFrame* wasm_frame = WasmFrame::cast(frame); | 532 WasmFrame* wasm_frame = WasmFrame::cast(frame); |
| 533 Code* code = wasm_frame->unchecked_code(); | 533 Code* code = wasm_frame->unchecked_code(); |
| 534 Handle<AbstractCode> abstract_code = | 534 Handle<AbstractCode> abstract_code = |
| 535 Handle<AbstractCode>(AbstractCode::cast(code)); | 535 Handle<AbstractCode>(AbstractCode::cast(code), this); |
| 536 int offset = | 536 int offset = |
| 537 static_cast<int>(wasm_frame->pc() - code->instruction_start()); | 537 static_cast<int>(wasm_frame->pc() - code->instruction_start()); |
| 538 elements = MaybeGrow(this, elements, cursor, cursor + 4); | 538 elements = MaybeGrow(this, elements, cursor, cursor + 4); |
| 539 elements->set(cursor++, wasm_frame->wasm_obj()); | 539 elements->set(cursor++, wasm_frame->wasm_obj()); |
| 540 elements->set(cursor++, Smi::FromInt(wasm_frame->function_index())); | 540 elements->set(cursor++, Smi::FromInt(wasm_frame->function_index())); |
| 541 elements->set(cursor++, *abstract_code); | 541 elements->set(cursor++, *abstract_code); |
| 542 elements->set(cursor++, Smi::FromInt(offset)); | 542 elements->set(cursor++, Smi::FromInt(offset)); |
| 543 frames_seen++; | 543 frames_seen++; |
| 544 } break; | 544 } break; |
| 545 | 545 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 Handle<JSObject> NewStackFrameObject(FrameSummary& summ) { | 635 Handle<JSObject> NewStackFrameObject(FrameSummary& summ) { |
| 636 int position = summ.abstract_code()->SourcePosition(summ.code_offset()); | 636 int position = summ.abstract_code()->SourcePosition(summ.code_offset()); |
| 637 return NewStackFrameObject(summ.function(), position, | 637 return NewStackFrameObject(summ.function(), position, |
| 638 summ.is_constructor()); | 638 summ.is_constructor()); |
| 639 } | 639 } |
| 640 | 640 |
| 641 Handle<JSObject> NewStackFrameObject(Handle<JSFunction> fun, int position, | 641 Handle<JSObject> NewStackFrameObject(Handle<JSFunction> fun, int position, |
| 642 bool is_constructor) { | 642 bool is_constructor) { |
| 643 Handle<JSObject> stack_frame = | 643 Handle<JSObject> stack_frame = |
| 644 factory()->NewJSObject(isolate_->object_function()); | 644 factory()->NewJSObject(isolate_->object_function()); |
| 645 Handle<Script> script(Script::cast(fun->shared()->script())); | 645 Handle<Script> script(Script::cast(fun->shared()->script()), isolate_); |
| 646 | 646 |
| 647 if (!line_key_.is_null()) { | 647 if (!line_key_.is_null()) { |
| 648 Script::PositionInfo info; | 648 Script::PositionInfo info; |
| 649 bool valid_pos = | 649 bool valid_pos = |
| 650 script->GetPositionInfo(position, &info, Script::WITH_OFFSET); | 650 script->GetPositionInfo(position, &info, Script::WITH_OFFSET); |
| 651 | 651 |
| 652 if (!column_key_.is_null() && valid_pos) { | 652 if (!column_key_.is_null() && valid_pos) { |
| 653 JSObject::AddProperty(stack_frame, column_key_, | 653 JSObject::AddProperty(stack_frame, column_key_, |
| 654 handle(Smi::FromInt(info.column + 1), isolate_), | 654 handle(Smi::FromInt(info.column + 1), isolate_), |
| 655 NONE); | 655 NONE); |
| (...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1397 } else { | 1397 } else { |
| 1398 DCHECK(frame->is_java_script() || frame->is_wasm()); | 1398 DCHECK(frame->is_java_script() || frame->is_wasm()); |
| 1399 Code* code = frame->LookupCode(); | 1399 Code* code = frame->LookupCode(); |
| 1400 abstract_code = AbstractCode::cast(code); | 1400 abstract_code = AbstractCode::cast(code); |
| 1401 code_offset = static_cast<int>(frame->pc() - code->instruction_start()); | 1401 code_offset = static_cast<int>(frame->pc() - code->instruction_start()); |
| 1402 } | 1402 } |
| 1403 int pos = abstract_code->SourcePosition(code_offset); | 1403 int pos = abstract_code->SourcePosition(code_offset); |
| 1404 JavaScriptFrame* js_frame = JavaScriptFrame::cast(frame); | 1404 JavaScriptFrame* js_frame = JavaScriptFrame::cast(frame); |
| 1405 Handle<Object> pos_obj(Smi::FromInt(pos), this); | 1405 Handle<Object> pos_obj(Smi::FromInt(pos), this); |
| 1406 // Fetch function and receiver. | 1406 // Fetch function and receiver. |
| 1407 Handle<JSFunction> fun(js_frame->function()); | 1407 Handle<JSFunction> fun(js_frame->function(), this); |
| 1408 Handle<Object> recv(js_frame->receiver(), this); | 1408 Handle<Object> recv(js_frame->receiver(), this); |
| 1409 // Advance to the next JavaScript frame and determine if the | 1409 // Advance to the next JavaScript frame and determine if the |
| 1410 // current frame is the top-level frame. | 1410 // current frame is the top-level frame. |
| 1411 it.Advance(); | 1411 it.Advance(); |
| 1412 Handle<Object> is_top_level = factory()->ToBoolean(it.done()); | 1412 Handle<Object> is_top_level = factory()->ToBoolean(it.done()); |
| 1413 // Generate and print stack trace line. | 1413 // Generate and print stack trace line. |
| 1414 Handle<String> line = | 1414 Handle<String> line = |
| 1415 Execution::GetStackTraceLine(recv, fun, pos_obj, is_top_level); | 1415 Execution::GetStackTraceLine(recv, fun, pos_obj, is_top_level); |
| 1416 if (line->length() > 0) { | 1416 if (line->length() > 0) { |
| 1417 line->PrintOn(out); | 1417 line->PrintOn(out); |
| 1418 PrintF(out, "\n"); | 1418 PrintF(out, "\n"); |
| 1419 } | 1419 } |
| 1420 } | 1420 } |
| 1421 } | 1421 } |
| 1422 | 1422 |
| 1423 bool Isolate::ComputeLocation(MessageLocation* target) { | 1423 bool Isolate::ComputeLocation(MessageLocation* target) { |
| 1424 StackTraceFrameIterator it(this); | 1424 StackTraceFrameIterator it(this); |
| 1425 if (it.done()) return false; | 1425 if (it.done()) return false; |
| 1426 StandardFrame* frame = it.frame(); | 1426 StandardFrame* frame = it.frame(); |
| 1427 // TODO(clemensh): handle wasm frames | 1427 // TODO(clemensh): handle wasm frames |
| 1428 if (!frame->is_java_script()) return false; | 1428 if (!frame->is_java_script()) return false; |
| 1429 JSFunction* fun = JavaScriptFrame::cast(frame)->function(); | 1429 JSFunction* fun = JavaScriptFrame::cast(frame)->function(); |
| 1430 Object* script = fun->shared()->script(); | 1430 Object* script = fun->shared()->script(); |
| 1431 if (!script->IsScript() || | 1431 if (!script->IsScript() || |
| 1432 (Script::cast(script)->source()->IsUndefined(this))) { | 1432 (Script::cast(script)->source()->IsUndefined(this))) { |
| 1433 return false; | 1433 return false; |
| 1434 } | 1434 } |
| 1435 Handle<Script> casted_script(Script::cast(script)); | 1435 Handle<Script> casted_script(Script::cast(script), this); |
| 1436 // Compute the location from the function and the relocation info of the | 1436 // Compute the location from the function and the relocation info of the |
| 1437 // baseline code. For optimized code this will use the deoptimization | 1437 // baseline code. For optimized code this will use the deoptimization |
| 1438 // information to get canonical location information. | 1438 // information to get canonical location information. |
| 1439 List<FrameSummary> frames(FLAG_max_inlining_levels + 1); | 1439 List<FrameSummary> frames(FLAG_max_inlining_levels + 1); |
| 1440 JavaScriptFrame::cast(frame)->Summarize(&frames); | 1440 JavaScriptFrame::cast(frame)->Summarize(&frames); |
| 1441 FrameSummary& summary = frames.last(); | 1441 FrameSummary& summary = frames.last(); |
| 1442 int pos = summary.abstract_code()->SourcePosition(summary.code_offset()); | 1442 int pos = summary.abstract_code()->SourcePosition(summary.code_offset()); |
| 1443 *target = MessageLocation(casted_script, pos, pos + 1, handle(fun)); | 1443 *target = MessageLocation(casted_script, pos, pos + 1, handle(fun, this)); |
| 1444 return true; | 1444 return true; |
| 1445 } | 1445 } |
| 1446 | 1446 |
| 1447 bool Isolate::ComputeLocationFromException(MessageLocation* target, | 1447 bool Isolate::ComputeLocationFromException(MessageLocation* target, |
| 1448 Handle<Object> exception) { | 1448 Handle<Object> exception) { |
| 1449 if (!exception->IsJSObject()) return false; | 1449 if (!exception->IsJSObject()) return false; |
| 1450 | 1450 |
| 1451 Handle<Name> start_pos_symbol = factory()->error_start_pos_symbol(); | 1451 Handle<Name> start_pos_symbol = factory()->error_start_pos_symbol(); |
| 1452 Handle<Object> start_pos = JSReceiver::GetDataProperty( | 1452 Handle<Object> start_pos = JSReceiver::GetDataProperty( |
| 1453 Handle<JSObject>::cast(exception), start_pos_symbol); | 1453 Handle<JSObject>::cast(exception), start_pos_symbol); |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1613 // Only report the exception if the external handler is verbose. | 1613 // Only report the exception if the external handler is verbose. |
| 1614 should_report_exception = try_catch_handler()->is_verbose_; | 1614 should_report_exception = try_catch_handler()->is_verbose_; |
| 1615 } else { | 1615 } else { |
| 1616 // Report the exception if it isn't caught by JavaScript code. | 1616 // Report the exception if it isn't caught by JavaScript code. |
| 1617 should_report_exception = !IsJavaScriptHandlerOnTop(exception); | 1617 should_report_exception = !IsJavaScriptHandlerOnTop(exception); |
| 1618 } | 1618 } |
| 1619 | 1619 |
| 1620 // Actually report the pending message to all message handlers. | 1620 // Actually report the pending message to all message handlers. |
| 1621 if (!message_obj->IsTheHole(this) && should_report_exception) { | 1621 if (!message_obj->IsTheHole(this) && should_report_exception) { |
| 1622 HandleScope scope(this); | 1622 HandleScope scope(this); |
| 1623 Handle<JSMessageObject> message(JSMessageObject::cast(message_obj)); | 1623 Handle<JSMessageObject> message(JSMessageObject::cast(message_obj), this); |
| 1624 Handle<JSValue> script_wrapper(JSValue::cast(message->script())); | 1624 Handle<JSValue> script_wrapper(JSValue::cast(message->script()), this); |
| 1625 Handle<Script> script(Script::cast(script_wrapper->value())); | 1625 Handle<Script> script(Script::cast(script_wrapper->value()), this); |
| 1626 int start_pos = message->start_position(); | 1626 int start_pos = message->start_position(); |
| 1627 int end_pos = message->end_position(); | 1627 int end_pos = message->end_position(); |
| 1628 MessageLocation location(script, start_pos, end_pos); | 1628 MessageLocation location(script, start_pos, end_pos); |
| 1629 MessageHandler::ReportMessage(this, &location, message); | 1629 MessageHandler::ReportMessage(this, &location, message); |
| 1630 } | 1630 } |
| 1631 } | 1631 } |
| 1632 | 1632 |
| 1633 | 1633 |
| 1634 MessageLocation Isolate::GetMessageLocation() { | 1634 MessageLocation Isolate::GetMessageLocation() { |
| 1635 DCHECK(has_pending_exception()); | 1635 DCHECK(has_pending_exception()); |
| 1636 | 1636 |
| 1637 if (thread_local_top_.pending_exception_ != heap()->termination_exception() && | 1637 if (thread_local_top_.pending_exception_ != heap()->termination_exception() && |
| 1638 !thread_local_top_.pending_message_obj_->IsTheHole(this)) { | 1638 !thread_local_top_.pending_message_obj_->IsTheHole(this)) { |
| 1639 Handle<JSMessageObject> message_obj( | 1639 Handle<JSMessageObject> message_obj( |
| 1640 JSMessageObject::cast(thread_local_top_.pending_message_obj_)); | 1640 JSMessageObject::cast(thread_local_top_.pending_message_obj_), this); |
| 1641 Handle<JSValue> script_wrapper(JSValue::cast(message_obj->script())); | 1641 Handle<JSValue> script_wrapper(JSValue::cast(message_obj->script()), this); |
| 1642 Handle<Script> script(Script::cast(script_wrapper->value())); | 1642 Handle<Script> script(Script::cast(script_wrapper->value()), this); |
| 1643 int start_pos = message_obj->start_position(); | 1643 int start_pos = message_obj->start_position(); |
| 1644 int end_pos = message_obj->end_position(); | 1644 int end_pos = message_obj->end_position(); |
| 1645 return MessageLocation(script, start_pos, end_pos); | 1645 return MessageLocation(script, start_pos, end_pos); |
| 1646 } | 1646 } |
| 1647 | 1647 |
| 1648 return MessageLocation(); | 1648 return MessageLocation(); |
| 1649 } | 1649 } |
| 1650 | 1650 |
| 1651 | 1651 |
| 1652 bool Isolate::OptionalRescheduleException(bool is_bottom_call) { | 1652 bool Isolate::OptionalRescheduleException(bool is_bottom_call) { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1742 stack_trace_for_uncaught_exceptions_options_ = options; | 1742 stack_trace_for_uncaught_exceptions_options_ = options; |
| 1743 } | 1743 } |
| 1744 | 1744 |
| 1745 | 1745 |
| 1746 void Isolate::SetAbortOnUncaughtExceptionCallback( | 1746 void Isolate::SetAbortOnUncaughtExceptionCallback( |
| 1747 v8::Isolate::AbortOnUncaughtExceptionCallback callback) { | 1747 v8::Isolate::AbortOnUncaughtExceptionCallback callback) { |
| 1748 abort_on_uncaught_exception_callback_ = callback; | 1748 abort_on_uncaught_exception_callback_ = callback; |
| 1749 } | 1749 } |
| 1750 | 1750 |
| 1751 | 1751 |
| 1752 Handle<Context> Isolate::native_context() { | |
| 1753 return handle(context()->native_context()); | |
| 1754 } | |
| 1755 | |
| 1756 | |
| 1757 Handle<Context> Isolate::GetCallingNativeContext() { | 1752 Handle<Context> Isolate::GetCallingNativeContext() { |
| 1758 JavaScriptFrameIterator it(this); | 1753 JavaScriptFrameIterator it(this); |
| 1759 if (debug_->in_debug_scope()) { | 1754 if (debug_->in_debug_scope()) { |
| 1760 while (!it.done()) { | 1755 while (!it.done()) { |
| 1761 JavaScriptFrame* frame = it.frame(); | 1756 JavaScriptFrame* frame = it.frame(); |
| 1762 Context* context = Context::cast(frame->context()); | 1757 Context* context = Context::cast(frame->context()); |
| 1763 if (context->native_context() == *debug_->debug_context()) { | 1758 if (context->native_context() == *debug_->debug_context()) { |
| 1764 it.Advance(); | 1759 it.Advance(); |
| 1765 } else { | 1760 } else { |
| 1766 break; | 1761 break; |
| 1767 } | 1762 } |
| 1768 } | 1763 } |
| 1769 } | 1764 } |
| 1770 if (it.done()) return Handle<Context>::null(); | 1765 if (it.done()) return Handle<Context>::null(); |
| 1771 JavaScriptFrame* frame = it.frame(); | 1766 JavaScriptFrame* frame = it.frame(); |
| 1772 Context* context = Context::cast(frame->context()); | 1767 Context* context = Context::cast(frame->context()); |
| 1773 return Handle<Context>(context->native_context()); | 1768 return Handle<Context>(context->native_context(), this); |
| 1774 } | 1769 } |
| 1775 | 1770 |
| 1776 | 1771 |
| 1777 char* Isolate::ArchiveThread(char* to) { | 1772 char* Isolate::ArchiveThread(char* to) { |
| 1778 MemCopy(to, reinterpret_cast<char*>(thread_local_top()), | 1773 MemCopy(to, reinterpret_cast<char*>(thread_local_top()), |
| 1779 sizeof(ThreadLocalTop)); | 1774 sizeof(ThreadLocalTop)); |
| 1780 InitializeThreadLocal(); | 1775 InitializeThreadLocal(); |
| 1781 clear_pending_exception(); | 1776 clear_pending_exception(); |
| 1782 clear_pending_message(); | 1777 clear_pending_message(); |
| 1783 clear_scheduled_exception(); | 1778 clear_scheduled_exception(); |
| (...skipping 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2801 void Isolate::RemoveBeforeCallEnteredCallback( | 2796 void Isolate::RemoveBeforeCallEnteredCallback( |
| 2802 BeforeCallEnteredCallback callback) { | 2797 BeforeCallEnteredCallback callback) { |
| 2803 for (int i = 0; i < before_call_entered_callbacks_.length(); i++) { | 2798 for (int i = 0; i < before_call_entered_callbacks_.length(); i++) { |
| 2804 if (callback == before_call_entered_callbacks_.at(i)) { | 2799 if (callback == before_call_entered_callbacks_.at(i)) { |
| 2805 before_call_entered_callbacks_.Remove(i); | 2800 before_call_entered_callbacks_.Remove(i); |
| 2806 } | 2801 } |
| 2807 } | 2802 } |
| 2808 } | 2803 } |
| 2809 | 2804 |
| 2810 | 2805 |
| 2811 void Isolate::FireBeforeCallEnteredCallback() { | |
| 2812 for (int i = 0; i < before_call_entered_callbacks_.length(); i++) { | |
| 2813 before_call_entered_callbacks_.at(i)(reinterpret_cast<v8::Isolate*>(this)); | |
| 2814 } | |
| 2815 } | |
| 2816 | |
| 2817 | |
| 2818 void Isolate::AddCallCompletedCallback(CallCompletedCallback callback) { | 2806 void Isolate::AddCallCompletedCallback(CallCompletedCallback callback) { |
| 2819 for (int i = 0; i < call_completed_callbacks_.length(); i++) { | 2807 for (int i = 0; i < call_completed_callbacks_.length(); i++) { |
| 2820 if (callback == call_completed_callbacks_.at(i)) return; | 2808 if (callback == call_completed_callbacks_.at(i)) return; |
| 2821 } | 2809 } |
| 2822 call_completed_callbacks_.Add(callback); | 2810 call_completed_callbacks_.Add(callback); |
| 2823 } | 2811 } |
| 2824 | 2812 |
| 2825 | 2813 |
| 2826 void Isolate::RemoveCallCompletedCallback(CallCompletedCallback callback) { | 2814 void Isolate::RemoveCallCompletedCallback(CallCompletedCallback callback) { |
| 2827 for (int i = 0; i < call_completed_callbacks_.length(); i++) { | 2815 for (int i = 0; i < call_completed_callbacks_.length(); i++) { |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3019 // deoptimize only those functions that are affected by the change of this | 3007 // deoptimize only those functions that are affected by the change of this |
| 3020 // flag. | 3008 // flag. |
| 3021 internal::Deoptimizer::DeoptimizeAll(this); | 3009 internal::Deoptimizer::DeoptimizeAll(this); |
| 3022 } | 3010 } |
| 3023 | 3011 |
| 3024 // Heap::detached_contexts tracks detached contexts as pairs | 3012 // Heap::detached_contexts tracks detached contexts as pairs |
| 3025 // (number of GC since the context was detached, the context). | 3013 // (number of GC since the context was detached, the context). |
| 3026 void Isolate::AddDetachedContext(Handle<Context> context) { | 3014 void Isolate::AddDetachedContext(Handle<Context> context) { |
| 3027 HandleScope scope(this); | 3015 HandleScope scope(this); |
| 3028 Handle<WeakCell> cell = factory()->NewWeakCell(context); | 3016 Handle<WeakCell> cell = factory()->NewWeakCell(context); |
| 3029 Handle<FixedArray> detached_contexts(heap()->detached_contexts()); | 3017 Handle<FixedArray> detached_contexts = factory()->detached_contexts(); |
| 3030 int length = detached_contexts->length(); | 3018 int length = detached_contexts->length(); |
| 3031 detached_contexts = factory()->CopyFixedArrayAndGrow(detached_contexts, 2); | 3019 detached_contexts = factory()->CopyFixedArrayAndGrow(detached_contexts, 2); |
| 3032 detached_contexts->set(length, Smi::FromInt(0)); | 3020 detached_contexts->set(length, Smi::FromInt(0)); |
| 3033 detached_contexts->set(length + 1, *cell); | 3021 detached_contexts->set(length + 1, *cell); |
| 3034 heap()->set_detached_contexts(*detached_contexts); | 3022 heap()->set_detached_contexts(*detached_contexts); |
| 3035 } | 3023 } |
| 3036 | 3024 |
| 3037 | 3025 |
| 3038 void Isolate::CheckDetachedContextsAfterGC() { | 3026 void Isolate::CheckDetachedContextsAfterGC() { |
| 3039 HandleScope scope(this); | 3027 HandleScope scope(this); |
| 3040 Handle<FixedArray> detached_contexts(heap()->detached_contexts()); | 3028 Handle<FixedArray> detached_contexts = factory()->detached_contexts(); |
| 3041 int length = detached_contexts->length(); | 3029 int length = detached_contexts->length(); |
| 3042 if (length == 0) return; | 3030 if (length == 0) return; |
| 3043 int new_length = 0; | 3031 int new_length = 0; |
| 3044 for (int i = 0; i < length; i += 2) { | 3032 for (int i = 0; i < length; i += 2) { |
| 3045 int mark_sweeps = Smi::cast(detached_contexts->get(i))->value(); | 3033 int mark_sweeps = Smi::cast(detached_contexts->get(i))->value(); |
| 3046 DCHECK(detached_contexts->get(i + 1)->IsWeakCell()); | 3034 DCHECK(detached_contexts->get(i + 1)->IsWeakCell()); |
| 3047 WeakCell* cell = WeakCell::cast(detached_contexts->get(i + 1)); | 3035 WeakCell* cell = WeakCell::cast(detached_contexts->get(i + 1)); |
| 3048 if (!cell->cleared()) { | 3036 if (!cell->cleared()) { |
| 3049 detached_contexts->set(new_length, Smi::FromInt(mark_sweeps + 1)); | 3037 detached_contexts->set(new_length, Smi::FromInt(mark_sweeps + 1)); |
| 3050 detached_contexts->set(new_length + 1, cell); | 3038 detached_contexts->set(new_length + 1, cell); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3121 // Then check whether this scope intercepts. | 3109 // Then check whether this scope intercepts. |
| 3122 if ((flag & intercept_mask_)) { | 3110 if ((flag & intercept_mask_)) { |
| 3123 intercepted_flags_ |= flag; | 3111 intercepted_flags_ |= flag; |
| 3124 return true; | 3112 return true; |
| 3125 } | 3113 } |
| 3126 return false; | 3114 return false; |
| 3127 } | 3115 } |
| 3128 | 3116 |
| 3129 } // namespace internal | 3117 } // namespace internal |
| 3130 } // namespace v8 | 3118 } // namespace v8 |
| OLD | NEW |