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

Side by Side Diff: src/source-position.cc

Issue 2703553002: Revert of Allow a ParseInfo without a script for %SetCode users (Closed)
Patch Set: Created 3 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
« no previous file with comments | « src/parsing/parse-info.cc ('k') | test/mjsunit/shared-function-tier-up-ignition.js » ('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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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/source-position.h" 5 #include "src/source-position.h"
6 #include "src/compilation-info.h" 6 #include "src/compilation-info.h"
7 #include "src/objects-inl.h" 7 #include "src/objects-inl.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
11 11
12 std::ostream& operator<<(std::ostream& out, const SourcePositionInfo& pos) { 12 std::ostream& operator<<(std::ostream& out, const SourcePositionInfo& pos) {
13 Handle<SharedFunctionInfo> function(pos.function); 13 Handle<SharedFunctionInfo> function(pos.function);
14 String* name = nullptr; 14 Handle<Script> script(Script::cast(function->script()));
15 if (function->script()->IsScript()) {
16 Script* script = Script::cast(function->script());
17 if (script->name()->IsString()) {
18 name = String::cast(script->name());
19 }
20 }
21 out << "<"; 15 out << "<";
22 if (name != nullptr) { 16 if (script->name()->IsString()) {
23 out << name->ToCString(DISALLOW_NULLS).get(); 17 out << String::cast(script->name())->ToCString(DISALLOW_NULLS).get();
24 } else { 18 } else {
25 out << "unknown"; 19 out << "unknown";
26 } 20 }
27 out << ":" << pos.line + 1 << ":" << pos.column + 1 << ">"; 21 out << ":" << pos.line + 1 << ":" << pos.column + 1 << ">";
28 return out; 22 return out;
29 } 23 }
30 24
31 std::ostream& operator<<(std::ostream& out, 25 std::ostream& operator<<(std::ostream& out,
32 const std::vector<SourcePositionInfo>& stack) { 26 const std::vector<SourcePositionInfo>& stack) {
33 bool first = true; 27 bool first = true;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 pos = inl.position; 71 pos = inl.position;
78 } 72 }
79 Handle<SharedFunctionInfo> function( 73 Handle<SharedFunctionInfo> function(
80 SharedFunctionInfo::cast(deopt_data->SharedFunctionInfo())); 74 SharedFunctionInfo::cast(deopt_data->SharedFunctionInfo()));
81 stack.push_back(SourcePositionInfo(pos, function)); 75 stack.push_back(SourcePositionInfo(pos, function));
82 return stack; 76 return stack;
83 } 77 }
84 78
85 void SourcePosition::Print(std::ostream& out, 79 void SourcePosition::Print(std::ostream& out,
86 SharedFunctionInfo* function) const { 80 SharedFunctionInfo* function) const {
81 Script* script = Script::cast(function->script());
82 Object* source_name = script->name();
87 Script::PositionInfo pos; 83 Script::PositionInfo pos;
88 Object* source_name = nullptr; 84 script->GetPositionInfo(ScriptOffset(), &pos, Script::WITH_OFFSET);
89 if (function->script()->IsScript()) {
90 Script* script = Script::cast(function->script());
91 source_name = script->name();
92 script->GetPositionInfo(ScriptOffset(), &pos, Script::WITH_OFFSET);
93 }
94 out << "<"; 85 out << "<";
95 if (source_name != nullptr && source_name->IsString()) { 86 if (source_name->IsString()) {
96 out << String::cast(source_name) 87 out << String::cast(source_name)
97 ->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL) 88 ->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL)
98 .get(); 89 .get();
99 } else { 90 } else {
100 out << "unknown"; 91 out << "unknown";
101 } 92 }
102 out << ":" << pos.line + 1 << ":" << pos.column + 1 << ">"; 93 out << ":" << pos.line + 1 << ":" << pos.column + 1 << ">";
103 } 94 }
104 95
105 void SourcePosition::Print(std::ostream& out, Code* code) const { 96 void SourcePosition::Print(std::ostream& out, Code* code) const {
(...skipping 13 matching lines...) Expand all
119 Print(out, function); 110 Print(out, function);
120 } 111 }
121 out << " inlined at "; 112 out << " inlined at ";
122 inl.position.Print(out, code); 113 inl.position.Print(out, code);
123 } 114 }
124 } 115 }
125 116
126 SourcePositionInfo::SourcePositionInfo(SourcePosition pos, 117 SourcePositionInfo::SourcePositionInfo(SourcePosition pos,
127 Handle<SharedFunctionInfo> f) 118 Handle<SharedFunctionInfo> f)
128 : position(pos), function(f) { 119 : position(pos), function(f) {
129 if (function->script()->IsScript()) { 120 Handle<Script> script(Script::cast(function->script()));
130 Handle<Script> script(Script::cast(function->script())); 121 Script::PositionInfo info;
131 Script::PositionInfo info; 122 if (Script::GetPositionInfo(script, pos.ScriptOffset(), &info,
132 if (Script::GetPositionInfo(script, pos.ScriptOffset(), &info, 123 Script::WITH_OFFSET)) {
133 Script::WITH_OFFSET)) { 124 line = info.line;
134 line = info.line; 125 column = info.column;
135 column = info.column;
136 }
137 } 126 }
138 } 127 }
139 128
140 } // namespace internal 129 } // namespace internal
141 } // namespace v8 130 } // namespace v8
OLDNEW
« no previous file with comments | « src/parsing/parse-info.cc ('k') | test/mjsunit/shared-function-tier-up-ignition.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698