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/deoptimizer.h" | |
11 #include "src/frames-inl.h" | 10 #include "src/frames-inl.h" |
12 #include "src/isolate-inl.h" | 11 #include "src/isolate-inl.h" |
13 #include "src/messages.h" | 12 #include "src/messages.h" |
14 #include "src/profiler/cpu-profiler.h" | 13 #include "src/profiler/cpu-profiler.h" |
15 | 14 |
16 namespace v8 { | 15 namespace v8 { |
17 namespace internal { | 16 namespace internal { |
18 | 17 |
19 RUNTIME_FUNCTION(Runtime_FunctionGetName) { | 18 RUNTIME_FUNCTION(Runtime_FunctionGetName) { |
20 SealHandleScope shs(isolate); | 19 SealHandleScope shs(isolate); |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 239 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
241 | 240 |
242 if (object->IsJSFunction()) { | 241 if (object->IsJSFunction()) { |
243 JSFunction* func = JSFunction::cast(*object); | 242 JSFunction* func = JSFunction::cast(*object); |
244 func->shared()->set_force_inline(true); | 243 func->shared()->set_force_inline(true); |
245 } | 244 } |
246 return isolate->heap()->undefined_value(); | 245 return isolate->heap()->undefined_value(); |
247 } | 246 } |
248 | 247 |
249 | 248 |
250 // Find the arguments of the JavaScript function invocation that called | |
251 // into C++ code. Collect these in a newly allocated array of handles (possibly | |
252 // prefixed by a number of empty handles). | |
253 base::SmartArrayPointer<Handle<Object>> Runtime::GetCallerArguments( | |
254 Isolate* isolate, int prefix_argc, int* total_argc) { | |
255 // Find frame containing arguments passed to the caller. | |
256 JavaScriptFrameIterator it(isolate); | |
257 JavaScriptFrame* frame = it.frame(); | |
258 List<JSFunction*> functions(2); | |
259 frame->GetFunctions(&functions); | |
260 if (functions.length() > 1) { | |
261 int inlined_jsframe_index = functions.length() - 1; | |
262 TranslatedState translated_values(frame); | |
263 translated_values.Prepare(false, frame->fp()); | |
264 | |
265 int argument_count = 0; | |
266 TranslatedFrame* translated_frame = | |
267 translated_values.GetArgumentsInfoFromJSFrameIndex( | |
268 inlined_jsframe_index, &argument_count); | |
269 TranslatedFrame::iterator iter = translated_frame->begin(); | |
270 | |
271 // Skip the function. | |
272 iter++; | |
273 | |
274 // Skip the receiver. | |
275 iter++; | |
276 argument_count--; | |
277 | |
278 *total_argc = prefix_argc + argument_count; | |
279 base::SmartArrayPointer<Handle<Object> > param_data( | |
280 NewArray<Handle<Object> >(*total_argc)); | |
281 bool should_deoptimize = false; | |
282 for (int i = 0; i < argument_count; i++) { | |
283 should_deoptimize = should_deoptimize || iter->IsMaterializedObject(); | |
284 Handle<Object> value = iter->GetValue(); | |
285 param_data[prefix_argc + i] = value; | |
286 iter++; | |
287 } | |
288 | |
289 if (should_deoptimize) { | |
290 translated_values.StoreMaterializedValuesAndDeopt(); | |
291 } | |
292 | |
293 return param_data; | |
294 } else { | |
295 it.AdvanceToArgumentsFrame(); | |
296 frame = it.frame(); | |
297 int args_count = frame->ComputeParametersCount(); | |
298 | |
299 *total_argc = prefix_argc + args_count; | |
300 base::SmartArrayPointer<Handle<Object> > param_data( | |
301 NewArray<Handle<Object> >(*total_argc)); | |
302 for (int i = 0; i < args_count; i++) { | |
303 Handle<Object> val = Handle<Object>(frame->GetParameter(i), isolate); | |
304 param_data[prefix_argc + i] = val; | |
305 } | |
306 return param_data; | |
307 } | |
308 } | |
309 | |
310 | |
311 RUNTIME_FUNCTION(Runtime_Call) { | 249 RUNTIME_FUNCTION(Runtime_Call) { |
312 HandleScope scope(isolate); | 250 HandleScope scope(isolate); |
313 DCHECK_LE(2, args.length()); | 251 DCHECK_LE(2, args.length()); |
314 int const argc = args.length() - 2; | 252 int const argc = args.length() - 2; |
315 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, target, 0); | 253 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, target, 0); |
316 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 1); | 254 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 1); |
317 ScopedVector<Handle<Object>> argv(argc); | 255 ScopedVector<Handle<Object>> argv(argc); |
318 for (int i = 0; i < argc; ++i) { | 256 for (int i = 0; i < argc; ++i) { |
319 argv[i] = args.at<Object>(2 + i); | 257 argv[i] = args.at<Object>(2 + i); |
320 } | 258 } |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 DCHECK_EQ(1, args.length()); | 352 DCHECK_EQ(1, args.length()); |
415 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, function, 0); | 353 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, function, 0); |
416 return function->IsJSBoundFunction() | 354 return function->IsJSBoundFunction() |
417 ? *JSBoundFunction::ToString( | 355 ? *JSBoundFunction::ToString( |
418 Handle<JSBoundFunction>::cast(function)) | 356 Handle<JSBoundFunction>::cast(function)) |
419 : *JSFunction::ToString(Handle<JSFunction>::cast(function)); | 357 : *JSFunction::ToString(Handle<JSFunction>::cast(function)); |
420 } | 358 } |
421 | 359 |
422 } // namespace internal | 360 } // namespace internal |
423 } // namespace v8 | 361 } // namespace v8 |
OLD | NEW |