| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/accessors.h" | 7 #include "src/accessors.h" |
| 8 #include "src/arguments.h" | 8 #include "src/arguments.h" |
| 9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
| 10 #include "src/deoptimizer.h" | 10 #include "src/deoptimizer.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 | 60 |
| 61 RUNTIME_FUNCTION(Runtime_FunctionGetName) { | 61 RUNTIME_FUNCTION(Runtime_FunctionGetName) { |
| 62 SealHandleScope shs(isolate); | 62 SealHandleScope shs(isolate); |
| 63 DCHECK(args.length() == 1); | 63 DCHECK(args.length() == 1); |
| 64 | 64 |
| 65 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 65 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
| 66 return f->shared()->name(); | 66 return f->shared()->name(); |
| 67 } | 67 } |
| 68 | 68 |
| 69 | 69 |
| 70 static Handle<String> NameToFunctionName(Handle<Name> name) { |
| 71 Handle<String> stringName(name->GetHeap()->empty_string()); |
| 72 |
| 73 // TODO(caitp): Follow proper rules in section 9.2.11 (SetFunctionName) |
| 74 if (name->IsSymbol()) { |
| 75 Handle<Object> description(Handle<Symbol>::cast(name)->name(), |
| 76 name->GetIsolate()); |
| 77 if (description->IsString()) { |
| 78 stringName = Handle<String>::cast(description); |
| 79 } |
| 80 } else { |
| 81 stringName = Handle<String>::cast(name); |
| 82 } |
| 83 |
| 84 return stringName; |
| 85 } |
| 86 |
| 87 |
| 70 RUNTIME_FUNCTION(Runtime_FunctionSetName) { | 88 RUNTIME_FUNCTION(Runtime_FunctionSetName) { |
| 71 SealHandleScope shs(isolate); | 89 HandleScope scope(isolate); |
| 72 DCHECK(args.length() == 2); | 90 DCHECK(args.length() == 2); |
| 73 | 91 |
| 74 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 92 CONVERT_ARG_HANDLE_CHECKED(JSFunction, f, 0); |
| 75 CONVERT_ARG_CHECKED(String, name, 1); | 93 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
| 76 f->shared()->set_name(name); | 94 |
| 95 f->shared()->set_name(*NameToFunctionName(name)); |
| 77 return isolate->heap()->undefined_value(); | 96 return isolate->heap()->undefined_value(); |
| 78 } | 97 } |
| 79 | 98 |
| 80 | 99 |
| 81 RUNTIME_FUNCTION(Runtime_FunctionNameShouldPrintAsAnonymous) { | 100 RUNTIME_FUNCTION(Runtime_FunctionNameShouldPrintAsAnonymous) { |
| 82 SealHandleScope shs(isolate); | 101 SealHandleScope shs(isolate); |
| 83 DCHECK(args.length() == 1); | 102 DCHECK(args.length() == 1); |
| 84 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 103 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
| 85 return isolate->heap()->ToBoolean( | 104 return isolate->heap()->ToBoolean( |
| 86 f->shared()->name_should_print_as_anonymous()); | 105 f->shared()->name_should_print_as_anonymous()); |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 | 616 |
| 598 | 617 |
| 599 RUNTIME_FUNCTION(RuntimeReference_IsFunction) { | 618 RUNTIME_FUNCTION(RuntimeReference_IsFunction) { |
| 600 SealHandleScope shs(isolate); | 619 SealHandleScope shs(isolate); |
| 601 DCHECK(args.length() == 1); | 620 DCHECK(args.length() == 1); |
| 602 CONVERT_ARG_CHECKED(Object, obj, 0); | 621 CONVERT_ARG_CHECKED(Object, obj, 0); |
| 603 return isolate->heap()->ToBoolean(obj->IsJSFunction()); | 622 return isolate->heap()->ToBoolean(obj->IsJSFunction()); |
| 604 } | 623 } |
| 605 } | 624 } |
| 606 } // namespace v8::internal | 625 } // namespace v8::internal |
| OLD | NEW |