Chromium Code Reviews| 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 String* NameToFunctionName(Isolate* isolate, Name* name) { | |
|
Dmitry Lomov (no reviews)
2014/10/24 08:20:47
This function shouldn't use naked pointers - use H
caitp (gmail)
2014/10/24 12:18:33
Done
| |
| 71 String* stringName = NULL; | |
|
Dmitry Lomov (no reviews)
2014/10/24 08:20:47
Handle<String>
| |
| 72 | |
| 73 // TODO(caitp): Follow proper rules in section 9.2.11 (SetFunctionName) | |
|
Dmitry Lomov (no reviews)
2014/10/24 08:20:47
Yes, fine to do in later CL - our names for getter
| |
| 74 if (name->IsSymbol()) { | |
| 75 Object* symName = Symbol::cast(name)->name(); | |
|
Dmitry Lomov (no reviews)
2014/10/24 08:20:47
Handle<Object> symName(Handle<Symbol>::cast(name)-
| |
| 76 if (symName->IsString()) { | |
| 77 stringName = String::cast(symName); | |
| 78 } | |
| 79 } else { | |
| 80 stringName = String::cast(name); | |
| 81 } | |
| 82 | |
| 83 if (stringName == NULL) { | |
| 84 stringName = isolate->heap()->empty_string(); | |
| 85 } | |
| 86 | |
| 87 return stringName; | |
| 88 } | |
| 89 | |
| 90 | |
| 70 RUNTIME_FUNCTION(Runtime_FunctionSetName) { | 91 RUNTIME_FUNCTION(Runtime_FunctionSetName) { |
| 71 SealHandleScope shs(isolate); | 92 SealHandleScope shs(isolate); |
| 72 DCHECK(args.length() == 2); | 93 DCHECK(args.length() == 2); |
| 73 | 94 |
| 74 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 95 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
| 75 CONVERT_ARG_CHECKED(String, name, 1); | 96 CONVERT_ARG_CHECKED(Name, name, 1); |
|
Dmitry Lomov (no reviews)
2014/10/24 08:20:47
CONVERT_ARG_HANDLE_CHECKED
In line 92 above, s/Se
| |
| 76 f->shared()->set_name(name); | 97 |
| 98 f->shared()->set_name(NameToFunctionName(isolate, name)); | |
| 77 return isolate->heap()->undefined_value(); | 99 return isolate->heap()->undefined_value(); |
| 78 } | 100 } |
| 79 | 101 |
| 80 | 102 |
| 81 RUNTIME_FUNCTION(Runtime_FunctionNameShouldPrintAsAnonymous) { | 103 RUNTIME_FUNCTION(Runtime_FunctionNameShouldPrintAsAnonymous) { |
| 82 SealHandleScope shs(isolate); | 104 SealHandleScope shs(isolate); |
| 83 DCHECK(args.length() == 1); | 105 DCHECK(args.length() == 1); |
| 84 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 106 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
| 85 return isolate->heap()->ToBoolean( | 107 return isolate->heap()->ToBoolean( |
| 86 f->shared()->name_should_print_as_anonymous()); | 108 f->shared()->name_should_print_as_anonymous()); |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 597 | 619 |
| 598 | 620 |
| 599 RUNTIME_FUNCTION(RuntimeReference_IsFunction) { | 621 RUNTIME_FUNCTION(RuntimeReference_IsFunction) { |
| 600 SealHandleScope shs(isolate); | 622 SealHandleScope shs(isolate); |
| 601 DCHECK(args.length() == 1); | 623 DCHECK(args.length() == 1); |
| 602 CONVERT_ARG_CHECKED(Object, obj, 0); | 624 CONVERT_ARG_CHECKED(Object, obj, 0); |
| 603 return isolate->heap()->ToBoolean(obj->IsJSFunction()); | 625 return isolate->heap()->ToBoolean(obj->IsJSFunction()); |
| 604 } | 626 } |
| 605 } | 627 } |
| 606 } // namespace v8::internal | 628 } // namespace v8::internal |
| OLD | NEW |