OLD | NEW |
---|---|
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/objects.h" | 5 #include "src/objects.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <iomanip> | 8 #include <iomanip> |
9 #include <memory> | 9 #include <memory> |
10 #include <sstream> | 10 #include <sstream> |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
229 } | 229 } |
230 | 230 |
231 Handle<String> NoSideEffectsErrorToString(Isolate* isolate, | 231 Handle<String> NoSideEffectsErrorToString(Isolate* isolate, |
232 Handle<Object> input) { | 232 Handle<Object> input) { |
233 Handle<JSReceiver> receiver = Handle<JSReceiver>::cast(input); | 233 Handle<JSReceiver> receiver = Handle<JSReceiver>::cast(input); |
234 | 234 |
235 Handle<Name> name_key = isolate->factory()->name_string(); | 235 Handle<Name> name_key = isolate->factory()->name_string(); |
236 Handle<Object> name = JSReceiver::GetDataProperty(receiver, name_key); | 236 Handle<Object> name = JSReceiver::GetDataProperty(receiver, name_key); |
237 Handle<String> name_str = (name->IsUndefined(isolate)) | 237 Handle<String> name_str = (name->IsUndefined(isolate)) |
238 ? isolate->factory()->Error_string() | 238 ? isolate->factory()->Error_string() |
239 : Object::NoSideEffectsToString(isolate, name); | 239 : Object::NoSideEffectsToString(isolate, name); |
Yang
2016/08/04 06:36:19
Can we simply break the recursion by not calling N
jgruber
2016/08/04 07:12:05
Done.
| |
240 | 240 |
241 Handle<Name> msg_key = isolate->factory()->message_string(); | 241 Handle<Name> msg_key = isolate->factory()->message_string(); |
242 Handle<Object> msg = JSReceiver::GetDataProperty(receiver, msg_key); | 242 Handle<Object> msg = JSReceiver::GetDataProperty(receiver, msg_key); |
243 Handle<String> msg_str = (msg->IsUndefined(isolate)) | 243 Handle<String> msg_str = (msg->IsUndefined(isolate)) |
244 ? isolate->factory()->empty_string() | 244 ? isolate->factory()->empty_string() |
245 : Object::NoSideEffectsToString(isolate, msg); | 245 : Object::NoSideEffectsToString(isolate, msg); |
246 | 246 |
247 if (name_str->length() == 0) return msg_str; | 247 if (name_str->length() == 0) return msg_str; |
248 if (msg_str->length() == 0) return name_str; | 248 if (msg_str->length() == 0) return name_str; |
249 | 249 |
250 IncrementalStringBuilder builder(isolate); | 250 IncrementalStringBuilder builder(isolate); |
251 builder.AppendString(name_str); | 251 builder.AppendString(name_str); |
252 builder.AppendCString(": "); | 252 builder.AppendCString(": "); |
253 builder.AppendString(msg_str); | 253 builder.AppendString(msg_str); |
254 | 254 |
255 return builder.Finish().ToHandleChecked(); | 255 return builder.Finish().ToHandleChecked(); |
256 } | 256 } |
257 | 257 |
258 } // namespace | 258 } // namespace |
259 | 259 |
260 // static | 260 // static |
261 Handle<String> Object::NoSideEffectsToString(Isolate* isolate, | 261 Handle<String> Object::NoSideEffectsToString(Isolate* isolate, |
262 Handle<Object> input) { | 262 Handle<Object> input) { |
263 StackLimitCheck stack_check(isolate); | |
264 if (stack_check.HasOverflowed()) { | |
265 return isolate->factory()->NewStringFromAsciiChecked("<stack overflow>"); | |
266 } | |
267 | |
263 DisallowJavascriptExecution no_js(isolate); | 268 DisallowJavascriptExecution no_js(isolate); |
264 | 269 |
265 if (input->IsString() || input->IsNumber() || input->IsOddball() || | 270 if (input->IsString() || input->IsNumber() || input->IsOddball() || |
266 input->IsSimd128Value()) { | 271 input->IsSimd128Value()) { |
267 return Object::ToString(isolate, input).ToHandleChecked(); | 272 return Object::ToString(isolate, input).ToHandleChecked(); |
268 } else if (input->IsFunction()) { | 273 } else if (input->IsFunction()) { |
269 // -- F u n c t i o n | 274 // -- F u n c t i o n |
270 Handle<String> fun_str; | 275 Handle<String> fun_str; |
271 if (input->IsJSBoundFunction()) { | 276 if (input->IsJSBoundFunction()) { |
272 fun_str = JSBoundFunction::ToString(Handle<JSBoundFunction>::cast(input)); | 277 fun_str = JSBoundFunction::ToString(Handle<JSBoundFunction>::cast(input)); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
314 receiver, isolate->factory()->constructor_string()); | 319 receiver, isolate->factory()->constructor_string()); |
315 if (ctor->IsFunction()) { | 320 if (ctor->IsFunction()) { |
316 Handle<String> ctor_name; | 321 Handle<String> ctor_name; |
317 if (ctor->IsJSBoundFunction()) { | 322 if (ctor->IsJSBoundFunction()) { |
318 ctor_name = JSBoundFunction::GetName( | 323 ctor_name = JSBoundFunction::GetName( |
319 isolate, Handle<JSBoundFunction>::cast(ctor)) | 324 isolate, Handle<JSBoundFunction>::cast(ctor)) |
320 .ToHandleChecked(); | 325 .ToHandleChecked(); |
321 } else if (ctor->IsJSFunction()) { | 326 } else if (ctor->IsJSFunction()) { |
322 Handle<Object> ctor_name_obj = | 327 Handle<Object> ctor_name_obj = |
323 JSFunction::GetName(isolate, Handle<JSFunction>::cast(ctor)); | 328 JSFunction::GetName(isolate, Handle<JSFunction>::cast(ctor)); |
324 ctor_name = NoSideEffectsToString(isolate, ctor_name_obj); | 329 ctor_name = NoSideEffectsToString(isolate, ctor_name_obj); |
Yang
2016/08/04 06:36:19
Same here.
jgruber
2016/08/04 07:12:05
Done.
| |
325 } | 330 } |
326 | 331 |
327 if (ctor_name->length() != 0) { | 332 if (ctor_name->length() != 0) { |
328 IncrementalStringBuilder builder(isolate); | 333 IncrementalStringBuilder builder(isolate); |
329 builder.AppendCString("#<"); | 334 builder.AppendCString("#<"); |
330 builder.AppendString(ctor_name); | 335 builder.AppendString(ctor_name); |
331 builder.AppendCString(">"); | 336 builder.AppendCString(">"); |
332 | 337 |
333 return builder.Finish().ToHandleChecked(); | 338 return builder.Finish().ToHandleChecked(); |
334 } | 339 } |
(...skipping 18850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
19185 for (PrototypeIterator iter(isolate, this, kStartAtReceiver, | 19190 for (PrototypeIterator iter(isolate, this, kStartAtReceiver, |
19186 PrototypeIterator::END_AT_NULL); | 19191 PrototypeIterator::END_AT_NULL); |
19187 !iter.IsAtEnd(); iter.AdvanceIgnoringProxies()) { | 19192 !iter.IsAtEnd(); iter.AdvanceIgnoringProxies()) { |
19188 if (iter.GetCurrent<Object>()->IsJSProxy()) return true; | 19193 if (iter.GetCurrent<Object>()->IsJSProxy()) return true; |
19189 } | 19194 } |
19190 return false; | 19195 return false; |
19191 } | 19196 } |
19192 | 19197 |
19193 } // namespace internal | 19198 } // namespace internal |
19194 } // namespace v8 | 19199 } // namespace v8 |
OLD | NEW |