| 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 DCHECK(args.length() == 1); | 48 DCHECK(args.length() == 1); |
| 49 | 49 |
| 50 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 50 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
| 51 CHECK(f->RemovePrototype()); | 51 CHECK(f->RemovePrototype()); |
| 52 f->shared()->SetConstructStub( | 52 f->shared()->SetConstructStub( |
| 53 *isolate->builtins()->ConstructedNonConstructable()); | 53 *isolate->builtins()->ConstructedNonConstructable()); |
| 54 | 54 |
| 55 return isolate->heap()->undefined_value(); | 55 return isolate->heap()->undefined_value(); |
| 56 } | 56 } |
| 57 | 57 |
| 58 | 58 // TODO(5530): Remove once uses in debug.js are gone. |
| 59 RUNTIME_FUNCTION(Runtime_FunctionGetScript) { | 59 RUNTIME_FUNCTION(Runtime_FunctionGetScript) { |
| 60 HandleScope scope(isolate); | 60 HandleScope scope(isolate); |
| 61 DCHECK_EQ(1, args.length()); | 61 DCHECK_EQ(1, args.length()); |
| 62 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, function, 0); | 62 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, function, 0); |
| 63 | 63 |
| 64 if (function->IsJSFunction()) { | 64 if (function->IsJSFunction()) { |
| 65 Handle<Object> script( | 65 Handle<Object> script( |
| 66 Handle<JSFunction>::cast(function)->shared()->script(), isolate); | 66 Handle<JSFunction>::cast(function)->shared()->script(), isolate); |
| 67 if (script->IsScript()) { | 67 if (script->IsScript()) { |
| 68 return *Script::GetWrapper(Handle<Script>::cast(script)); | 68 return *Script::GetWrapper(Handle<Script>::cast(script)); |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 return isolate->heap()->undefined_value(); | 71 return isolate->heap()->undefined_value(); |
| 72 } | 72 } |
| 73 | 73 |
| 74 RUNTIME_FUNCTION(Runtime_FunctionGetScriptId) { |
| 75 HandleScope scope(isolate); |
| 76 DCHECK_EQ(1, args.length()); |
| 77 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, function, 0); |
| 78 |
| 79 if (function->IsJSFunction()) { |
| 80 Handle<Object> script( |
| 81 Handle<JSFunction>::cast(function)->shared()->script(), isolate); |
| 82 if (script->IsScript()) { |
| 83 return Smi::FromInt(Handle<Script>::cast(script)->id()); |
| 84 } |
| 85 } |
| 86 return Smi::FromInt(-1); |
| 87 } |
| 74 | 88 |
| 75 RUNTIME_FUNCTION(Runtime_FunctionGetSourceCode) { | 89 RUNTIME_FUNCTION(Runtime_FunctionGetSourceCode) { |
| 76 HandleScope scope(isolate); | 90 HandleScope scope(isolate); |
| 77 DCHECK_EQ(1, args.length()); | 91 DCHECK_EQ(1, args.length()); |
| 78 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, function, 0); | 92 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, function, 0); |
| 79 if (function->IsJSFunction()) { | 93 if (function->IsJSFunction()) { |
| 80 return *Handle<JSFunction>::cast(function)->shared()->GetSourceCode(); | 94 return *Handle<JSFunction>::cast(function)->shared()->GetSourceCode(); |
| 81 } | 95 } |
| 82 return isolate->heap()->undefined_value(); | 96 return isolate->heap()->undefined_value(); |
| 83 } | 97 } |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 DCHECK_EQ(1, args.length()); | 301 DCHECK_EQ(1, args.length()); |
| 288 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, function, 0); | 302 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, function, 0); |
| 289 return function->IsJSBoundFunction() | 303 return function->IsJSBoundFunction() |
| 290 ? *JSBoundFunction::ToString( | 304 ? *JSBoundFunction::ToString( |
| 291 Handle<JSBoundFunction>::cast(function)) | 305 Handle<JSBoundFunction>::cast(function)) |
| 292 : *JSFunction::ToString(Handle<JSFunction>::cast(function)); | 306 : *JSFunction::ToString(Handle<JSFunction>::cast(function)); |
| 293 } | 307 } |
| 294 | 308 |
| 295 } // namespace internal | 309 } // namespace internal |
| 296 } // namespace v8 | 310 } // namespace v8 |
| OLD | NEW |