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/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/bootstrapper.h" | 8 #include "src/bootstrapper.h" |
9 #include "src/debug.h" | 9 #include "src/debug.h" |
10 #include "src/messages.h" | 10 #include "src/messages.h" |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 CONVERT_ARG_HANDLE_CHECKED(String, arg1, 2); | 315 CONVERT_ARG_HANDLE_CHECKED(String, arg1, 2); |
316 CONVERT_ARG_HANDLE_CHECKED(String, arg2, 3); | 316 CONVERT_ARG_HANDLE_CHECKED(String, arg2, 3); |
317 Handle<String> result; | 317 Handle<String> result; |
318 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 318 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
319 isolate, result, | 319 isolate, result, |
320 MessageTemplate::FormatMessage(template_index, arg0, arg1, arg2)); | 320 MessageTemplate::FormatMessage(template_index, arg0, arg1, arg2)); |
321 return *result; | 321 return *result; |
322 } | 322 } |
323 | 323 |
324 | 324 |
| 325 #define CALLSITE_GET(NAME, RETURN) \ |
| 326 RUNTIME_FUNCTION(Runtime_CallSite##NAME##RT) { \ |
| 327 HandleScope scope(isolate); \ |
| 328 DCHECK(args.length() == 3); \ |
| 329 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); \ |
| 330 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 1); \ |
| 331 CONVERT_INT32_ARG_CHECKED(pos, 2); \ |
| 332 Handle<String> result; \ |
| 333 CallSite call_site(receiver, fun, pos); \ |
| 334 return RETURN(call_site.NAME(isolate), isolate); \ |
| 335 } |
| 336 |
| 337 static inline Object* ReturnDereferencedHandle(Handle<Object> obj, |
| 338 Isolate* isolate) { |
| 339 return *obj; |
| 340 } |
| 341 |
| 342 |
| 343 static inline Object* ReturnPositiveSmiOrNull(int value, Isolate* isolate) { |
| 344 if (value >= 0) return Smi::FromInt(value); |
| 345 return isolate->heap()->null_value(); |
| 346 } |
| 347 |
| 348 |
| 349 static inline Object* ReturnBoolean(bool value, Isolate* isolate) { |
| 350 return isolate->heap()->ToBoolean(value); |
| 351 } |
| 352 |
| 353 |
| 354 CALLSITE_GET(GetFileName, ReturnDereferencedHandle) |
| 355 CALLSITE_GET(GetFunctionName, ReturnDereferencedHandle) |
| 356 CALLSITE_GET(GetScriptNameOrSourceUrl, ReturnDereferencedHandle) |
| 357 CALLSITE_GET(GetLineNumber, ReturnPositiveSmiOrNull) |
| 358 CALLSITE_GET(GetColumnNumber, ReturnPositiveSmiOrNull) |
| 359 CALLSITE_GET(IsNative, ReturnBoolean) |
| 360 CALLSITE_GET(IsToplevel, ReturnBoolean) |
| 361 CALLSITE_GET(IsEval, ReturnBoolean) |
| 362 |
| 363 #undef CALLSITE_GET |
| 364 |
| 365 |
325 RUNTIME_FUNCTION(Runtime_IS_VAR) { | 366 RUNTIME_FUNCTION(Runtime_IS_VAR) { |
326 UNREACHABLE(); // implemented as macro in the parser | 367 UNREACHABLE(); // implemented as macro in the parser |
327 return NULL; | 368 return NULL; |
328 } | 369 } |
329 | 370 |
330 | 371 |
331 RUNTIME_FUNCTION(Runtime_GetFromCache) { | 372 RUNTIME_FUNCTION(Runtime_GetFromCache) { |
332 HandleScope scope(isolate); | 373 HandleScope scope(isolate); |
333 DCHECK(args.length() == 2); | 374 DCHECK(args.length() == 2); |
334 CONVERT_SMI_ARG_CHECKED(id, 0); | 375 CONVERT_SMI_ARG_CHECKED(id, 0); |
(...skipping 25 matching lines...) Expand all Loading... |
360 return args[0]; | 401 return args[0]; |
361 } | 402 } |
362 | 403 |
363 | 404 |
364 RUNTIME_FUNCTION(Runtime_HarmonyToString) { | 405 RUNTIME_FUNCTION(Runtime_HarmonyToString) { |
365 // TODO(caitp): Delete this runtime method when removing --harmony-tostring | 406 // TODO(caitp): Delete this runtime method when removing --harmony-tostring |
366 return isolate->heap()->ToBoolean(FLAG_harmony_tostring); | 407 return isolate->heap()->ToBoolean(FLAG_harmony_tostring); |
367 } | 408 } |
368 } | 409 } |
369 } // namespace v8::internal | 410 } // namespace v8::internal |
OLD | NEW |