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

Side by Side Diff: src/api.cc

Issue 6368051: A MessageObject is a purely internal object to hold information about (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address comments Created 9 years, 10 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 | « include/v8.h ('k') | src/bootstrapper.cc » ('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 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 1460 matching lines...) Expand 10 before | Expand all | Expand 10 after
1471 return scope.Close(result); 1471 return scope.Close(result);
1472 } 1472 }
1473 1473
1474 1474
1475 v8::Handle<Value> Message::GetScriptResourceName() const { 1475 v8::Handle<Value> Message::GetScriptResourceName() const {
1476 if (IsDeadCheck("v8::Message::GetScriptResourceName()")) { 1476 if (IsDeadCheck("v8::Message::GetScriptResourceName()")) {
1477 return Local<String>(); 1477 return Local<String>();
1478 } 1478 }
1479 ENTER_V8; 1479 ENTER_V8;
1480 HandleScope scope; 1480 HandleScope scope;
1481 i::Handle<i::JSObject> obj = 1481 i::Handle<i::JSMessageObject> message =
1482 i::Handle<i::JSObject>::cast(Utils::OpenHandle(this)); 1482 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this));
1483 // Return this.script.name. 1483 // Return this.script.name.
1484 i::Handle<i::JSValue> script = 1484 i::Handle<i::JSValue> script =
1485 i::Handle<i::JSValue>::cast(GetProperty(obj, "script")); 1485 i::Handle<i::JSValue>::cast(i::Handle<i::Object>(message->script()));
1486 i::Handle<i::Object> resource_name(i::Script::cast(script->value())->name()); 1486 i::Handle<i::Object> resource_name(i::Script::cast(script->value())->name());
1487 return scope.Close(Utils::ToLocal(resource_name)); 1487 return scope.Close(Utils::ToLocal(resource_name));
1488 } 1488 }
1489 1489
1490 1490
1491 v8::Handle<Value> Message::GetScriptData() const { 1491 v8::Handle<Value> Message::GetScriptData() const {
1492 if (IsDeadCheck("v8::Message::GetScriptResourceData()")) { 1492 if (IsDeadCheck("v8::Message::GetScriptResourceData()")) {
1493 return Local<Value>(); 1493 return Local<Value>();
1494 } 1494 }
1495 ENTER_V8; 1495 ENTER_V8;
1496 HandleScope scope; 1496 HandleScope scope;
1497 i::Handle<i::JSObject> obj = 1497 i::Handle<i::JSMessageObject> message =
1498 i::Handle<i::JSObject>::cast(Utils::OpenHandle(this)); 1498 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this));
1499 // Return this.script.data. 1499 // Return this.script.data.
1500 i::Handle<i::JSValue> script = 1500 i::Handle<i::JSValue> script =
1501 i::Handle<i::JSValue>::cast(GetProperty(obj, "script")); 1501 i::Handle<i::JSValue>::cast(i::Handle<i::Object>(message->script()));
1502 i::Handle<i::Object> data(i::Script::cast(script->value())->data()); 1502 i::Handle<i::Object> data(i::Script::cast(script->value())->data());
1503 return scope.Close(Utils::ToLocal(data)); 1503 return scope.Close(Utils::ToLocal(data));
1504 } 1504 }
1505 1505
1506 1506
1507 v8::Handle<v8::StackTrace> Message::GetStackTrace() const { 1507 v8::Handle<v8::StackTrace> Message::GetStackTrace() const {
1508 if (IsDeadCheck("v8::Message::GetStackTrace()")) { 1508 if (IsDeadCheck("v8::Message::GetStackTrace()")) {
1509 return Local<v8::StackTrace>(); 1509 return Local<v8::StackTrace>();
1510 } 1510 }
1511 ENTER_V8; 1511 ENTER_V8;
1512 HandleScope scope; 1512 HandleScope scope;
1513 i::Handle<i::JSObject> obj = 1513 i::Handle<i::JSMessageObject> message =
1514 i::Handle<i::JSObject>::cast(Utils::OpenHandle(this)); 1514 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this));
1515 i::Handle<i::Object> stackFramesObj = GetProperty(obj, "stackFrames"); 1515 i::Handle<i::Object> stackFramesObj(message->stack_frames());
1516 if (!stackFramesObj->IsJSArray()) return v8::Handle<v8::StackTrace>(); 1516 if (!stackFramesObj->IsJSArray()) return v8::Handle<v8::StackTrace>();
1517 i::Handle<i::JSArray> stackTrace = 1517 i::Handle<i::JSArray> stackTrace =
1518 i::Handle<i::JSArray>::cast(stackFramesObj); 1518 i::Handle<i::JSArray>::cast(stackFramesObj);
1519 return scope.Close(Utils::StackTraceToLocal(stackTrace)); 1519 return scope.Close(Utils::StackTraceToLocal(stackTrace));
1520 } 1520 }
1521 1521
1522 1522
1523 static i::Handle<i::Object> CallV8HeapFunction(const char* name, 1523 static i::Handle<i::Object> CallV8HeapFunction(const char* name,
1524 i::Handle<i::Object> recv, 1524 i::Handle<i::Object> recv,
1525 int argc, 1525 int argc,
(...skipping 19 matching lines...) Expand all
1545 1, 1545 1,
1546 argv, 1546 argv,
1547 has_pending_exception); 1547 has_pending_exception);
1548 } 1548 }
1549 1549
1550 1550
1551 int Message::GetLineNumber() const { 1551 int Message::GetLineNumber() const {
1552 ON_BAILOUT("v8::Message::GetLineNumber()", return kNoLineNumberInfo); 1552 ON_BAILOUT("v8::Message::GetLineNumber()", return kNoLineNumberInfo);
1553 ENTER_V8; 1553 ENTER_V8;
1554 HandleScope scope; 1554 HandleScope scope;
1555
1555 EXCEPTION_PREAMBLE(); 1556 EXCEPTION_PREAMBLE();
1556 i::Handle<i::Object> result = CallV8HeapFunction("GetLineNumber", 1557 i::Handle<i::Object> result = CallV8HeapFunction("GetLineNumber",
1557 Utils::OpenHandle(this), 1558 Utils::OpenHandle(this),
1558 &has_pending_exception); 1559 &has_pending_exception);
1559 EXCEPTION_BAILOUT_CHECK(0); 1560 EXCEPTION_BAILOUT_CHECK(0);
1560 return static_cast<int>(result->Number()); 1561 return static_cast<int>(result->Number());
1561 } 1562 }
1562 1563
1563 1564
1564 int Message::GetStartPosition() const { 1565 int Message::GetStartPosition() const {
1565 if (IsDeadCheck("v8::Message::GetStartPosition()")) return 0; 1566 if (IsDeadCheck("v8::Message::GetStartPosition()")) return 0;
1566 ENTER_V8; 1567 ENTER_V8;
1567 HandleScope scope; 1568 HandleScope scope;
1568 1569 i::Handle<i::JSMessageObject> message =
1569 i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this); 1570 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this));
1570 return static_cast<int>(GetProperty(data_obj, "startPos")->Number()); 1571 return message->start_position();
1571 } 1572 }
1572 1573
1573 1574
1574 int Message::GetEndPosition() const { 1575 int Message::GetEndPosition() const {
1575 if (IsDeadCheck("v8::Message::GetEndPosition()")) return 0; 1576 if (IsDeadCheck("v8::Message::GetEndPosition()")) return 0;
1576 ENTER_V8; 1577 ENTER_V8;
1577 HandleScope scope; 1578 HandleScope scope;
1578 i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this); 1579 i::Handle<i::JSMessageObject> message =
1579 return static_cast<int>(GetProperty(data_obj, "endPos")->Number()); 1580 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this));
1581 return message->end_position();
1580 } 1582 }
1581 1583
1582 1584
1583 int Message::GetStartColumn() const { 1585 int Message::GetStartColumn() const {
1584 if (IsDeadCheck("v8::Message::GetStartColumn()")) return kNoColumnInfo; 1586 if (IsDeadCheck("v8::Message::GetStartColumn()")) return kNoColumnInfo;
1585 ENTER_V8; 1587 ENTER_V8;
1586 HandleScope scope; 1588 HandleScope scope;
1587 i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this); 1589 i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this);
1588 EXCEPTION_PREAMBLE(); 1590 EXCEPTION_PREAMBLE();
1589 i::Handle<i::Object> start_col_obj = CallV8HeapFunction( 1591 i::Handle<i::Object> start_col_obj = CallV8HeapFunction(
1590 "GetPositionInLine", 1592 "GetPositionInLine",
1591 data_obj, 1593 data_obj,
1592 &has_pending_exception); 1594 &has_pending_exception);
1593 EXCEPTION_BAILOUT_CHECK(0); 1595 EXCEPTION_BAILOUT_CHECK(0);
1594 return static_cast<int>(start_col_obj->Number()); 1596 return static_cast<int>(start_col_obj->Number());
1595 } 1597 }
1596 1598
1597 1599
1598 int Message::GetEndColumn() const { 1600 int Message::GetEndColumn() const {
1599 if (IsDeadCheck("v8::Message::GetEndColumn()")) return kNoColumnInfo; 1601 if (IsDeadCheck("v8::Message::GetEndColumn()")) return kNoColumnInfo;
1600 ENTER_V8; 1602 ENTER_V8;
1601 HandleScope scope; 1603 HandleScope scope;
1602 i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this); 1604 i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this);
1603 EXCEPTION_PREAMBLE(); 1605 EXCEPTION_PREAMBLE();
1604 i::Handle<i::Object> start_col_obj = CallV8HeapFunction( 1606 i::Handle<i::Object> start_col_obj = CallV8HeapFunction(
1605 "GetPositionInLine", 1607 "GetPositionInLine",
1606 data_obj, 1608 data_obj,
1607 &has_pending_exception); 1609 &has_pending_exception);
1608 EXCEPTION_BAILOUT_CHECK(0); 1610 EXCEPTION_BAILOUT_CHECK(0);
1609 int start = static_cast<int>(GetProperty(data_obj, "startPos")->Number()); 1611 i::Handle<i::JSMessageObject> message =
1610 int end = static_cast<int>(GetProperty(data_obj, "endPos")->Number()); 1612 i::Handle<i::JSMessageObject>::cast(data_obj);
1613 int start = message->start_position();
1614 int end = message->end_position();
1611 return static_cast<int>(start_col_obj->Number()) + (end - start); 1615 return static_cast<int>(start_col_obj->Number()) + (end - start);
1612 } 1616 }
1613 1617
1614 1618
1615 Local<String> Message::GetSourceLine() const { 1619 Local<String> Message::GetSourceLine() const {
1616 ON_BAILOUT("v8::Message::GetSourceLine()", return Local<String>()); 1620 ON_BAILOUT("v8::Message::GetSourceLine()", return Local<String>());
1617 ENTER_V8; 1621 ENTER_V8;
1618 HandleScope scope; 1622 HandleScope scope;
1619 EXCEPTION_PREAMBLE(); 1623 EXCEPTION_PREAMBLE();
1620 i::Handle<i::Object> result = CallV8HeapFunction("GetSourceLine", 1624 i::Handle<i::Object> result = CallV8HeapFunction("GetSourceLine",
(...skipping 3535 matching lines...) Expand 10 before | Expand all | Expand 10 after
5156 5160
5157 5161
5158 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { 5162 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) {
5159 HandleScopeImplementer* thread_local = 5163 HandleScopeImplementer* thread_local =
5160 reinterpret_cast<HandleScopeImplementer*>(storage); 5164 reinterpret_cast<HandleScopeImplementer*>(storage);
5161 thread_local->IterateThis(v); 5165 thread_local->IterateThis(v);
5162 return storage + ArchiveSpacePerThread(); 5166 return storage + ArchiveSpacePerThread();
5163 } 5167 }
5164 5168
5165 } } // namespace v8::internal 5169 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698