| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 "Entering the V8 API without proper locking in place"); \ | 109 "Entering the V8 API without proper locking in place"); \ |
| 110 } \ | 110 } \ |
| 111 } while (false) | 111 } while (false) |
| 112 | 112 |
| 113 | 113 |
| 114 // --- E x c e p t i o n B e h a v i o r --- | 114 // --- E x c e p t i o n B e h a v i o r --- |
| 115 | 115 |
| 116 | 116 |
| 117 static void DefaultFatalErrorHandler(const char* location, | 117 static void DefaultFatalErrorHandler(const char* location, |
| 118 const char* message) { | 118 const char* message) { |
| 119 ENTER_V8; | 119 #ifdef ENABLE_VMSTATE_TRACKING |
| 120 i::VMState __state__(i::Isolate::Current(), i::OTHER); |
| 121 #endif |
| 120 API_Fatal(location, message); | 122 API_Fatal(location, message); |
| 121 } | 123 } |
| 122 | 124 |
| 123 | 125 |
| 124 static FatalErrorCallback GetFatalErrorHandler() { | 126 static FatalErrorCallback GetFatalErrorHandler() { |
| 125 i::Isolate* isolate = i::Isolate::Current(); | 127 i::Isolate* isolate = i::Isolate::Current(); |
| 126 if (isolate->exception_behavior() == NULL) { | 128 if (isolate->exception_behavior() == NULL) { |
| 127 isolate->set_exception_behavior(DefaultFatalErrorHandler); | 129 isolate->set_exception_behavior(DefaultFatalErrorHandler); |
| 128 } | 130 } |
| 129 return isolate->exception_behavior(); | 131 return isolate->exception_behavior(); |
| (...skipping 1371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1501 return scope.Close(result); | 1503 return scope.Close(result); |
| 1502 } | 1504 } |
| 1503 | 1505 |
| 1504 | 1506 |
| 1505 v8::Handle<Value> Message::GetScriptResourceName() const { | 1507 v8::Handle<Value> Message::GetScriptResourceName() const { |
| 1506 if (IsDeadCheck("v8::Message::GetScriptResourceName()")) { | 1508 if (IsDeadCheck("v8::Message::GetScriptResourceName()")) { |
| 1507 return Local<String>(); | 1509 return Local<String>(); |
| 1508 } | 1510 } |
| 1509 ENTER_V8; | 1511 ENTER_V8; |
| 1510 HandleScope scope; | 1512 HandleScope scope; |
| 1511 i::Handle<i::JSObject> obj = | 1513 i::Handle<i::JSMessageObject> message = |
| 1512 i::Handle<i::JSObject>::cast(Utils::OpenHandle(this)); | 1514 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); |
| 1513 // Return this.script.name. | 1515 // Return this.script.name. |
| 1514 i::Handle<i::JSValue> script = | 1516 i::Handle<i::JSValue> script = |
| 1515 i::Handle<i::JSValue>::cast(GetProperty(obj, "script")); | 1517 i::Handle<i::JSValue>::cast(i::Handle<i::Object>(message->script())); |
| 1516 i::Handle<i::Object> resource_name(i::Script::cast(script->value())->name()); | 1518 i::Handle<i::Object> resource_name(i::Script::cast(script->value())->name()); |
| 1517 return scope.Close(Utils::ToLocal(resource_name)); | 1519 return scope.Close(Utils::ToLocal(resource_name)); |
| 1518 } | 1520 } |
| 1519 | 1521 |
| 1520 | 1522 |
| 1521 v8::Handle<Value> Message::GetScriptData() const { | 1523 v8::Handle<Value> Message::GetScriptData() const { |
| 1522 if (IsDeadCheck("v8::Message::GetScriptResourceData()")) { | 1524 if (IsDeadCheck("v8::Message::GetScriptResourceData()")) { |
| 1523 return Local<Value>(); | 1525 return Local<Value>(); |
| 1524 } | 1526 } |
| 1525 ENTER_V8; | 1527 ENTER_V8; |
| 1526 HandleScope scope; | 1528 HandleScope scope; |
| 1527 i::Handle<i::JSObject> obj = | 1529 i::Handle<i::JSMessageObject> message = |
| 1528 i::Handle<i::JSObject>::cast(Utils::OpenHandle(this)); | 1530 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); |
| 1529 // Return this.script.data. | 1531 // Return this.script.data. |
| 1530 i::Handle<i::JSValue> script = | 1532 i::Handle<i::JSValue> script = |
| 1531 i::Handle<i::JSValue>::cast(GetProperty(obj, "script")); | 1533 i::Handle<i::JSValue>::cast(i::Handle<i::Object>(message->script())); |
| 1532 i::Handle<i::Object> data(i::Script::cast(script->value())->data()); | 1534 i::Handle<i::Object> data(i::Script::cast(script->value())->data()); |
| 1533 return scope.Close(Utils::ToLocal(data)); | 1535 return scope.Close(Utils::ToLocal(data)); |
| 1534 } | 1536 } |
| 1535 | 1537 |
| 1536 | 1538 |
| 1537 v8::Handle<v8::StackTrace> Message::GetStackTrace() const { | 1539 v8::Handle<v8::StackTrace> Message::GetStackTrace() const { |
| 1538 if (IsDeadCheck("v8::Message::GetStackTrace()")) { | 1540 if (IsDeadCheck("v8::Message::GetStackTrace()")) { |
| 1539 return Local<v8::StackTrace>(); | 1541 return Local<v8::StackTrace>(); |
| 1540 } | 1542 } |
| 1541 ENTER_V8; | 1543 ENTER_V8; |
| 1542 HandleScope scope; | 1544 HandleScope scope; |
| 1543 i::Handle<i::JSObject> obj = | 1545 i::Handle<i::JSMessageObject> message = |
| 1544 i::Handle<i::JSObject>::cast(Utils::OpenHandle(this)); | 1546 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); |
| 1545 i::Handle<i::Object> stackFramesObj = GetProperty(obj, "stackFrames"); | 1547 i::Handle<i::Object> stackFramesObj(message->stack_frames()); |
| 1546 if (!stackFramesObj->IsJSArray()) return v8::Handle<v8::StackTrace>(); | 1548 if (!stackFramesObj->IsJSArray()) return v8::Handle<v8::StackTrace>(); |
| 1547 i::Handle<i::JSArray> stackTrace = | 1549 i::Handle<i::JSArray> stackTrace = |
| 1548 i::Handle<i::JSArray>::cast(stackFramesObj); | 1550 i::Handle<i::JSArray>::cast(stackFramesObj); |
| 1549 return scope.Close(Utils::StackTraceToLocal(stackTrace)); | 1551 return scope.Close(Utils::StackTraceToLocal(stackTrace)); |
| 1550 } | 1552 } |
| 1551 | 1553 |
| 1552 | 1554 |
| 1553 static i::Handle<i::Object> CallV8HeapFunction(const char* name, | 1555 static i::Handle<i::Object> CallV8HeapFunction(const char* name, |
| 1554 i::Handle<i::Object> recv, | 1556 i::Handle<i::Object> recv, |
| 1555 int argc, | 1557 int argc, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1576 1, | 1578 1, |
| 1577 argv, | 1579 argv, |
| 1578 has_pending_exception); | 1580 has_pending_exception); |
| 1579 } | 1581 } |
| 1580 | 1582 |
| 1581 | 1583 |
| 1582 int Message::GetLineNumber() const { | 1584 int Message::GetLineNumber() const { |
| 1583 ON_BAILOUT("v8::Message::GetLineNumber()", return kNoLineNumberInfo); | 1585 ON_BAILOUT("v8::Message::GetLineNumber()", return kNoLineNumberInfo); |
| 1584 ENTER_V8; | 1586 ENTER_V8; |
| 1585 HandleScope scope; | 1587 HandleScope scope; |
| 1588 |
| 1586 EXCEPTION_PREAMBLE(); | 1589 EXCEPTION_PREAMBLE(); |
| 1587 i::Handle<i::Object> result = CallV8HeapFunction("GetLineNumber", | 1590 i::Handle<i::Object> result = CallV8HeapFunction("GetLineNumber", |
| 1588 Utils::OpenHandle(this), | 1591 Utils::OpenHandle(this), |
| 1589 &has_pending_exception); | 1592 &has_pending_exception); |
| 1590 EXCEPTION_BAILOUT_CHECK(0); | 1593 EXCEPTION_BAILOUT_CHECK(0); |
| 1591 return static_cast<int>(result->Number()); | 1594 return static_cast<int>(result->Number()); |
| 1592 } | 1595 } |
| 1593 | 1596 |
| 1594 | 1597 |
| 1595 int Message::GetStartPosition() const { | 1598 int Message::GetStartPosition() const { |
| 1596 if (IsDeadCheck("v8::Message::GetStartPosition()")) return 0; | 1599 if (IsDeadCheck("v8::Message::GetStartPosition()")) return 0; |
| 1597 ENTER_V8; | 1600 ENTER_V8; |
| 1598 HandleScope scope; | 1601 HandleScope scope; |
| 1599 | 1602 i::Handle<i::JSMessageObject> message = |
| 1600 i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this); | 1603 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); |
| 1601 return static_cast<int>(GetProperty(data_obj, "startPos")->Number()); | 1604 return message->start_position(); |
| 1602 } | 1605 } |
| 1603 | 1606 |
| 1604 | 1607 |
| 1605 int Message::GetEndPosition() const { | 1608 int Message::GetEndPosition() const { |
| 1606 if (IsDeadCheck("v8::Message::GetEndPosition()")) return 0; | 1609 if (IsDeadCheck("v8::Message::GetEndPosition()")) return 0; |
| 1607 ENTER_V8; | 1610 ENTER_V8; |
| 1608 HandleScope scope; | 1611 HandleScope scope; |
| 1609 i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this); | 1612 i::Handle<i::JSMessageObject> message = |
| 1610 return static_cast<int>(GetProperty(data_obj, "endPos")->Number()); | 1613 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); |
| 1614 return message->end_position(); |
| 1611 } | 1615 } |
| 1612 | 1616 |
| 1613 | 1617 |
| 1614 int Message::GetStartColumn() const { | 1618 int Message::GetStartColumn() const { |
| 1615 if (IsDeadCheck("v8::Message::GetStartColumn()")) return kNoColumnInfo; | 1619 if (IsDeadCheck("v8::Message::GetStartColumn()")) return kNoColumnInfo; |
| 1616 ENTER_V8; | 1620 ENTER_V8; |
| 1617 HandleScope scope; | 1621 HandleScope scope; |
| 1618 i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this); | 1622 i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this); |
| 1619 EXCEPTION_PREAMBLE(); | 1623 EXCEPTION_PREAMBLE(); |
| 1620 i::Handle<i::Object> start_col_obj = CallV8HeapFunction( | 1624 i::Handle<i::Object> start_col_obj = CallV8HeapFunction( |
| 1621 "GetPositionInLine", | 1625 "GetPositionInLine", |
| 1622 data_obj, | 1626 data_obj, |
| 1623 &has_pending_exception); | 1627 &has_pending_exception); |
| 1624 EXCEPTION_BAILOUT_CHECK(0); | 1628 EXCEPTION_BAILOUT_CHECK(0); |
| 1625 return static_cast<int>(start_col_obj->Number()); | 1629 return static_cast<int>(start_col_obj->Number()); |
| 1626 } | 1630 } |
| 1627 | 1631 |
| 1628 | 1632 |
| 1629 int Message::GetEndColumn() const { | 1633 int Message::GetEndColumn() const { |
| 1630 if (IsDeadCheck("v8::Message::GetEndColumn()")) return kNoColumnInfo; | 1634 if (IsDeadCheck("v8::Message::GetEndColumn()")) return kNoColumnInfo; |
| 1631 ENTER_V8; | 1635 ENTER_V8; |
| 1632 HandleScope scope; | 1636 HandleScope scope; |
| 1633 i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this); | 1637 i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this); |
| 1634 EXCEPTION_PREAMBLE(); | 1638 EXCEPTION_PREAMBLE(); |
| 1635 i::Handle<i::Object> start_col_obj = CallV8HeapFunction( | 1639 i::Handle<i::Object> start_col_obj = CallV8HeapFunction( |
| 1636 "GetPositionInLine", | 1640 "GetPositionInLine", |
| 1637 data_obj, | 1641 data_obj, |
| 1638 &has_pending_exception); | 1642 &has_pending_exception); |
| 1639 EXCEPTION_BAILOUT_CHECK(0); | 1643 EXCEPTION_BAILOUT_CHECK(0); |
| 1640 int start = static_cast<int>(GetProperty(data_obj, "startPos")->Number()); | 1644 i::Handle<i::JSMessageObject> message = |
| 1641 int end = static_cast<int>(GetProperty(data_obj, "endPos")->Number()); | 1645 i::Handle<i::JSMessageObject>::cast(data_obj); |
| 1646 int start = message->start_position(); |
| 1647 int end = message->end_position(); |
| 1642 return static_cast<int>(start_col_obj->Number()) + (end - start); | 1648 return static_cast<int>(start_col_obj->Number()) + (end - start); |
| 1643 } | 1649 } |
| 1644 | 1650 |
| 1645 | 1651 |
| 1646 Local<String> Message::GetSourceLine() const { | 1652 Local<String> Message::GetSourceLine() const { |
| 1647 ON_BAILOUT("v8::Message::GetSourceLine()", return Local<String>()); | 1653 ON_BAILOUT("v8::Message::GetSourceLine()", return Local<String>()); |
| 1648 ENTER_V8; | 1654 ENTER_V8; |
| 1649 HandleScope scope; | 1655 HandleScope scope; |
| 1650 EXCEPTION_PREAMBLE(); | 1656 EXCEPTION_PREAMBLE(); |
| 1651 i::Handle<i::Object> result = CallV8HeapFunction("GetSourceLine", | 1657 i::Handle<i::Object> result = CallV8HeapFunction("GetSourceLine", |
| (...skipping 3526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5178 | 5184 |
| 5179 | 5185 |
| 5180 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { | 5186 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { |
| 5181 HandleScopeImplementer* thread_local = | 5187 HandleScopeImplementer* thread_local = |
| 5182 reinterpret_cast<HandleScopeImplementer*>(storage); | 5188 reinterpret_cast<HandleScopeImplementer*>(storage); |
| 5183 thread_local->IterateThis(v); | 5189 thread_local->IterateThis(v); |
| 5184 return storage + ArchiveSpacePerThread(); | 5190 return storage + ArchiveSpacePerThread(); |
| 5185 } | 5191 } |
| 5186 | 5192 |
| 5187 } } // namespace v8::internal | 5193 } } // namespace v8::internal |
| OLD | NEW |