OLD | NEW |
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 1589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1600 i::Handle<i::Script> script(i::Script::cast(function_info->script())); | 1600 i::Handle<i::Script> script(i::Script::cast(function_info->script())); |
1601 script->set_data(*raw_data); | 1601 script->set_data(*raw_data); |
1602 } | 1602 } |
1603 } | 1603 } |
1604 | 1604 |
1605 | 1605 |
1606 // --- E x c e p t i o n s --- | 1606 // --- E x c e p t i o n s --- |
1607 | 1607 |
1608 | 1608 |
1609 v8::TryCatch::TryCatch() | 1609 v8::TryCatch::TryCatch() |
1610 : next_(i::Isolate::Current()->try_catch_handler_address()), | 1610 : isolate_(i::Isolate::Current()), |
1611 exception_(HEAP->the_hole_value()), | 1611 next_(isolate_->try_catch_handler_address()), |
| 1612 exception_(isolate_->heap()->the_hole_value()), |
1612 message_(i::Smi::FromInt(0)), | 1613 message_(i::Smi::FromInt(0)), |
1613 is_verbose_(false), | 1614 is_verbose_(false), |
1614 can_continue_(true), | 1615 can_continue_(true), |
1615 capture_message_(true), | 1616 capture_message_(true), |
1616 rethrow_(false) { | 1617 rethrow_(false) { |
1617 i::Isolate::Current()->RegisterTryCatchHandler(this); | 1618 isolate_->RegisterTryCatchHandler(this); |
1618 } | 1619 } |
1619 | 1620 |
1620 | 1621 |
1621 v8::TryCatch::~TryCatch() { | 1622 v8::TryCatch::~TryCatch() { |
1622 i::Isolate* isolate = i::Isolate::Current(); | 1623 ASSERT(isolate_ == i::Isolate::Current()); |
1623 if (rethrow_) { | 1624 if (rethrow_) { |
1624 v8::HandleScope scope; | 1625 v8::HandleScope scope; |
1625 v8::Local<v8::Value> exc = v8::Local<v8::Value>::New(Exception()); | 1626 v8::Local<v8::Value> exc = v8::Local<v8::Value>::New(Exception()); |
1626 isolate->UnregisterTryCatchHandler(this); | 1627 isolate_->UnregisterTryCatchHandler(this); |
1627 v8::ThrowException(exc); | 1628 v8::ThrowException(exc); |
1628 } else { | 1629 } else { |
1629 isolate->UnregisterTryCatchHandler(this); | 1630 isolate_->UnregisterTryCatchHandler(this); |
1630 } | 1631 } |
1631 } | 1632 } |
1632 | 1633 |
1633 | 1634 |
1634 bool v8::TryCatch::HasCaught() const { | 1635 bool v8::TryCatch::HasCaught() const { |
1635 return !reinterpret_cast<i::Object*>(exception_)->IsTheHole(); | 1636 return !reinterpret_cast<i::Object*>(exception_)->IsTheHole(); |
1636 } | 1637 } |
1637 | 1638 |
1638 | 1639 |
1639 bool v8::TryCatch::CanContinue() const { | 1640 bool v8::TryCatch::CanContinue() const { |
1640 return can_continue_; | 1641 return can_continue_; |
1641 } | 1642 } |
1642 | 1643 |
1643 | 1644 |
1644 v8::Handle<v8::Value> v8::TryCatch::ReThrow() { | 1645 v8::Handle<v8::Value> v8::TryCatch::ReThrow() { |
1645 if (!HasCaught()) return v8::Local<v8::Value>(); | 1646 if (!HasCaught()) return v8::Local<v8::Value>(); |
1646 rethrow_ = true; | 1647 rethrow_ = true; |
1647 return v8::Undefined(); | 1648 return v8::Undefined(); |
1648 } | 1649 } |
1649 | 1650 |
1650 | 1651 |
1651 v8::Local<Value> v8::TryCatch::Exception() const { | 1652 v8::Local<Value> v8::TryCatch::Exception() const { |
| 1653 ASSERT(isolate_ == i::Isolate::Current()); |
1652 if (HasCaught()) { | 1654 if (HasCaught()) { |
1653 // Check for out of memory exception. | 1655 // Check for out of memory exception. |
1654 i::Object* exception = reinterpret_cast<i::Object*>(exception_); | 1656 i::Object* exception = reinterpret_cast<i::Object*>(exception_); |
1655 return v8::Utils::ToLocal(i::Handle<i::Object>(exception)); | 1657 return v8::Utils::ToLocal(i::Handle<i::Object>(exception, isolate_)); |
1656 } else { | 1658 } else { |
1657 return v8::Local<Value>(); | 1659 return v8::Local<Value>(); |
1658 } | 1660 } |
1659 } | 1661 } |
1660 | 1662 |
1661 | 1663 |
1662 v8::Local<Value> v8::TryCatch::StackTrace() const { | 1664 v8::Local<Value> v8::TryCatch::StackTrace() const { |
| 1665 ASSERT(isolate_ == i::Isolate::Current()); |
1663 if (HasCaught()) { | 1666 if (HasCaught()) { |
1664 i::Object* raw_obj = reinterpret_cast<i::Object*>(exception_); | 1667 i::Object* raw_obj = reinterpret_cast<i::Object*>(exception_); |
1665 if (!raw_obj->IsJSObject()) return v8::Local<Value>(); | 1668 if (!raw_obj->IsJSObject()) return v8::Local<Value>(); |
1666 v8::HandleScope scope; | 1669 i::HandleScope scope(isolate_); |
1667 i::Handle<i::JSObject> obj(i::JSObject::cast(raw_obj)); | 1670 i::Handle<i::JSObject> obj(i::JSObject::cast(raw_obj), isolate_); |
1668 i::Handle<i::String> name = FACTORY->LookupAsciiSymbol("stack"); | 1671 i::Handle<i::String> name = isolate_->factory()->LookupAsciiSymbol("stack"); |
1669 if (!obj->HasProperty(*name)) | 1672 if (!obj->HasProperty(*name)) return v8::Local<Value>(); |
1670 return v8::Local<Value>(); | 1673 return v8::Utils::ToLocal(scope.CloseAndEscape(i::GetProperty(obj, name))); |
1671 return scope.Close(v8::Utils::ToLocal(i::GetProperty(obj, name))); | |
1672 } else { | 1674 } else { |
1673 return v8::Local<Value>(); | 1675 return v8::Local<Value>(); |
1674 } | 1676 } |
1675 } | 1677 } |
1676 | 1678 |
1677 | 1679 |
1678 v8::Local<v8::Message> v8::TryCatch::Message() const { | 1680 v8::Local<v8::Message> v8::TryCatch::Message() const { |
| 1681 ASSERT(isolate_ == i::Isolate::Current()); |
1679 if (HasCaught() && message_ != i::Smi::FromInt(0)) { | 1682 if (HasCaught() && message_ != i::Smi::FromInt(0)) { |
1680 i::Object* message = reinterpret_cast<i::Object*>(message_); | 1683 i::Object* message = reinterpret_cast<i::Object*>(message_); |
1681 return v8::Utils::MessageToLocal(i::Handle<i::Object>(message)); | 1684 return v8::Utils::MessageToLocal(i::Handle<i::Object>(message, isolate_)); |
1682 } else { | 1685 } else { |
1683 return v8::Local<v8::Message>(); | 1686 return v8::Local<v8::Message>(); |
1684 } | 1687 } |
1685 } | 1688 } |
1686 | 1689 |
1687 | 1690 |
1688 void v8::TryCatch::Reset() { | 1691 void v8::TryCatch::Reset() { |
1689 exception_ = HEAP->the_hole_value(); | 1692 ASSERT(isolate_ == i::Isolate::Current()); |
| 1693 exception_ = isolate_->heap()->the_hole_value(); |
1690 message_ = i::Smi::FromInt(0); | 1694 message_ = i::Smi::FromInt(0); |
1691 } | 1695 } |
1692 | 1696 |
1693 | 1697 |
1694 void v8::TryCatch::SetVerbose(bool value) { | 1698 void v8::TryCatch::SetVerbose(bool value) { |
1695 is_verbose_ = value; | 1699 is_verbose_ = value; |
1696 } | 1700 } |
1697 | 1701 |
1698 | 1702 |
1699 void v8::TryCatch::SetCaptureMessage(bool value) { | 1703 void v8::TryCatch::SetCaptureMessage(bool value) { |
(...skipping 4389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6089 | 6093 |
6090 | 6094 |
6091 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { | 6095 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { |
6092 HandleScopeImplementer* scope_implementer = | 6096 HandleScopeImplementer* scope_implementer = |
6093 reinterpret_cast<HandleScopeImplementer*>(storage); | 6097 reinterpret_cast<HandleScopeImplementer*>(storage); |
6094 scope_implementer->IterateThis(v); | 6098 scope_implementer->IterateThis(v); |
6095 return storage + ArchiveSpacePerThread(); | 6099 return storage + ArchiveSpacePerThread(); |
6096 } | 6100 } |
6097 | 6101 |
6098 } } // namespace v8::internal | 6102 } } // namespace v8::internal |
OLD | NEW |