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/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.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/frames-inl.h" | 10 #include "src/frames-inl.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 | 48 |
49 return isolate->heap()->undefined_value(); | 49 return isolate->heap()->undefined_value(); |
50 } | 50 } |
51 | 51 |
52 | 52 |
53 RUNTIME_FUNCTION(Runtime_FunctionGetScript) { | 53 RUNTIME_FUNCTION(Runtime_FunctionGetScript) { |
54 HandleScope scope(isolate); | 54 HandleScope scope(isolate); |
55 DCHECK_EQ(1, args.length()); | 55 DCHECK_EQ(1, args.length()); |
56 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, function, 0); | 56 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, function, 0); |
57 | 57 |
58 if (function->IsJSBoundFunction()) return isolate->heap()->undefined_value(); | 58 if (function->IsJSFunction()) { |
59 Handle<Object> script(Handle<JSFunction>::cast(function)->shared()->script(), | 59 Handle<Object> script( |
60 isolate); | 60 Handle<JSFunction>::cast(function)->shared()->script(), isolate); |
61 if (!script->IsScript()) return isolate->heap()->undefined_value(); | 61 if (script->IsScript()) { |
62 return *Script::GetWrapper(Handle<Script>::cast(script)); | 62 return *Script::GetWrapper(Handle<Script>::cast(script)); |
| 63 } |
| 64 } |
| 65 return isolate->heap()->undefined_value(); |
63 } | 66 } |
64 | 67 |
65 | 68 |
66 RUNTIME_FUNCTION(Runtime_FunctionGetSourceCode) { | 69 RUNTIME_FUNCTION(Runtime_FunctionGetSourceCode) { |
67 HandleScope scope(isolate); | 70 HandleScope scope(isolate); |
68 DCHECK_EQ(1, args.length()); | 71 DCHECK_EQ(1, args.length()); |
69 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, function, 0); | 72 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, function, 0); |
70 if (function->IsJSBoundFunction()) return isolate->heap()->undefined_value(); | 73 if (function->IsJSFunction()) { |
71 return *Handle<JSFunction>::cast(function)->shared()->GetSourceCode(); | 74 return *Handle<JSFunction>::cast(function)->shared()->GetSourceCode(); |
| 75 } |
| 76 return isolate->heap()->undefined_value(); |
72 } | 77 } |
73 | 78 |
74 | 79 |
75 RUNTIME_FUNCTION(Runtime_FunctionGetScriptSourcePosition) { | 80 RUNTIME_FUNCTION(Runtime_FunctionGetScriptSourcePosition) { |
76 SealHandleScope shs(isolate); | 81 SealHandleScope shs(isolate); |
77 DCHECK(args.length() == 1); | 82 DCHECK(args.length() == 1); |
78 | 83 |
79 CONVERT_ARG_CHECKED(JSFunction, fun, 0); | 84 CONVERT_ARG_CHECKED(JSFunction, fun, 0); |
80 int pos = fun->shared()->start_position(); | 85 int pos = fun->shared()->start_position(); |
81 return Smi::FromInt(pos); | 86 return Smi::FromInt(pos); |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 DCHECK_EQ(1, args.length()); | 356 DCHECK_EQ(1, args.length()); |
352 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, function, 0); | 357 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, function, 0); |
353 return function->IsJSBoundFunction() | 358 return function->IsJSBoundFunction() |
354 ? *JSBoundFunction::ToString( | 359 ? *JSBoundFunction::ToString( |
355 Handle<JSBoundFunction>::cast(function)) | 360 Handle<JSBoundFunction>::cast(function)) |
356 : *JSFunction::ToString(Handle<JSFunction>::cast(function)); | 361 : *JSFunction::ToString(Handle<JSFunction>::cast(function)); |
357 } | 362 } |
358 | 363 |
359 } // namespace internal | 364 } // namespace internal |
360 } // namespace v8 | 365 } // namespace v8 |
OLD | NEW |