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

Side by Side Diff: src/messages.cc

Issue 1122973002: Move more parts of stack trace formatting to runtime. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: addressed comments Created 5 years, 7 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/messages.h ('k') | src/messages.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/execution.h" 8 #include "src/execution.h"
9 #include "src/heap/spaces-inl.h" 9 #include "src/heap/spaces-inl.h"
10 #include "src/messages.h" 10 #include "src/messages.h"
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 if (script_obj->IsScript()) { 190 if (script_obj->IsScript()) {
191 Handle<Script> script = Handle<Script>::cast(script_obj); 191 Handle<Script> script = Handle<Script>::cast(script_obj);
192 Object* source_url = script->source_url(); 192 Object* source_url = script->source_url();
193 if (source_url->IsString()) return Handle<Object>(source_url, isolate); 193 if (source_url->IsString()) return Handle<Object>(source_url, isolate);
194 return Handle<Object>(script->name(), isolate); 194 return Handle<Object>(script->name(), isolate);
195 } 195 }
196 return isolate->factory()->null_value(); 196 return isolate->factory()->null_value();
197 } 197 }
198 198
199 199
200 bool CheckMethodName(Handle<JSObject> obj, Handle<Name> name,
201 Handle<JSFunction> fun,
202 LookupIterator::Configuration config) {
203 LookupIterator iter(obj, name, config);
204 if (iter.state() == LookupIterator::DATA) {
205 return iter.GetDataValue().is_identical_to(fun);
206 } else if (iter.state() == LookupIterator::ACCESSOR) {
207 Handle<Object> accessors = iter.GetAccessors();
208 if (accessors->IsAccessorPair()) {
209 Handle<AccessorPair> pair = Handle<AccessorPair>::cast(accessors);
210 return pair->getter() == *fun || pair->setter() == *fun;
211 }
212 }
213 return false;
214 }
215
216
217 Handle<Object> CallSite::GetMethodName(Isolate* isolate) {
218 MaybeHandle<JSReceiver> maybe = Object::ToObject(isolate, receiver_);
219 Handle<JSReceiver> receiver;
220 if (!maybe.ToHandle(&receiver) || !receiver->IsJSObject()) {
221 return isolate->factory()->null_value();
222 }
223
224 Handle<JSObject> obj = Handle<JSObject>::cast(receiver);
225 Handle<Object> function_name(fun_->shared()->name(), isolate);
226 if (function_name->IsName()) {
227 Handle<Name> name = Handle<Name>::cast(function_name);
228 if (CheckMethodName(obj, name, fun_,
229 LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR))
230 return name;
231 }
232
233 HandleScope outer_scope(isolate);
234 Handle<Object> result;
235 for (PrototypeIterator iter(isolate, obj,
236 PrototypeIterator::START_AT_RECEIVER);
237 !iter.IsAtEnd(); iter.Advance()) {
238 Handle<Object> current = PrototypeIterator::GetCurrent(iter);
239 if (!current->IsJSObject()) break;
240 Handle<JSObject> current_obj = Handle<JSObject>::cast(current);
241 if (current_obj->IsAccessCheckNeeded()) break;
242 Handle<FixedArray> keys = JSObject::GetEnumPropertyKeys(current_obj, false);
243 for (int i = 0; i < keys->length(); i++) {
244 HandleScope inner_scope(isolate);
245 if (!keys->get(i)->IsName()) continue;
246 Handle<Name> name_key(Name::cast(keys->get(i)), isolate);
247 if (!CheckMethodName(current_obj, name_key, fun_,
248 LookupIterator::OWN_SKIP_INTERCEPTOR))
249 continue;
250 // Return null in case of duplicates to avoid confusion.
251 if (!result.is_null()) return isolate->factory()->null_value();
252 result = inner_scope.CloseAndEscape(name_key);
253 }
254 }
255
256 if (!result.is_null()) return outer_scope.CloseAndEscape(result);
257 return isolate->factory()->null_value();
258 }
259
260
200 int CallSite::GetLineNumber(Isolate* isolate) { 261 int CallSite::GetLineNumber(Isolate* isolate) {
201 if (pos_ >= 0) { 262 if (pos_ >= 0) {
202 Handle<Object> script_obj(fun_->shared()->script(), isolate); 263 Handle<Object> script_obj(fun_->shared()->script(), isolate);
203 if (script_obj->IsScript()) { 264 if (script_obj->IsScript()) {
204 Handle<Script> script = Handle<Script>::cast(script_obj); 265 Handle<Script> script = Handle<Script>::cast(script_obj);
205 return Script::GetLineNumber(script, pos_) + 1; 266 return Script::GetLineNumber(script, pos_) + 1;
206 } 267 }
207 } 268 }
208 return -1; 269 return -1;
209 } 270 }
(...skipping 25 matching lines...) Expand all
235 296
236 297
237 bool CallSite::IsEval(Isolate* isolate) { 298 bool CallSite::IsEval(Isolate* isolate) {
238 Handle<Object> script(fun_->shared()->script(), isolate); 299 Handle<Object> script(fun_->shared()->script(), isolate);
239 return script->IsScript() && 300 return script->IsScript() &&
240 Handle<Script>::cast(script)->compilation_type() == 301 Handle<Script>::cast(script)->compilation_type() ==
241 Script::COMPILATION_TYPE_EVAL; 302 Script::COMPILATION_TYPE_EVAL;
242 } 303 }
243 304
244 305
306 bool CallSite::IsConstructor(Isolate* isolate) {
307 if (!receiver_->IsJSObject()) return false;
308 Handle<Object> constructor =
309 JSObject::GetDataProperty(Handle<JSObject>::cast(receiver_),
310 isolate->factory()->constructor_string());
311 return constructor.is_identical_to(fun_);
312 }
313
314
245 MaybeHandle<String> MessageTemplate::FormatMessage(int template_index, 315 MaybeHandle<String> MessageTemplate::FormatMessage(int template_index,
246 Handle<String> arg0, 316 Handle<String> arg0,
247 Handle<String> arg1, 317 Handle<String> arg1,
248 Handle<String> arg2) { 318 Handle<String> arg2) {
249 const char* template_string; 319 const char* template_string;
250 switch (template_index) { 320 switch (template_index) {
251 #define CASE(NAME, STRING) \ 321 #define CASE(NAME, STRING) \
252 case k##NAME: \ 322 case k##NAME: \
253 template_string = STRING; \ 323 template_string = STRING; \
254 break; 324 break;
(...skipping 16 matching lines...) Expand all
271 DCHECK(i < arraysize(args)); 341 DCHECK(i < arraysize(args));
272 builder.AppendString(args[i++]); 342 builder.AppendString(args[i++]);
273 } else { 343 } else {
274 builder.AppendCharacter(*c); 344 builder.AppendCharacter(*c);
275 } 345 }
276 } 346 }
277 347
278 return builder.Finish(); 348 return builder.Finish();
279 } 349 }
280 } } // namespace v8::internal 350 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/messages.h ('k') | src/messages.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698