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/deoptimizer.h" | 8 #include "src/deoptimizer.h" |
9 #include "src/full-codegen.h" | 9 #include "src/full-codegen.h" |
10 #include "src/runtime/runtime.h" | 10 #include "src/runtime/runtime.h" |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 DCHECK(args.length() == 1); | 285 DCHECK(args.length() == 1); |
286 CONVERT_ARG_HANDLE_CHECKED(String, message, 0); | 286 CONVERT_ARG_HANDLE_CHECKED(String, message, 0); |
287 base::OS::PrintError("abort: %s\n", message->ToCString().get()); | 287 base::OS::PrintError("abort: %s\n", message->ToCString().get()); |
288 isolate->PrintStack(stderr); | 288 isolate->PrintStack(stderr); |
289 base::OS::Abort(); | 289 base::OS::Abort(); |
290 UNREACHABLE(); | 290 UNREACHABLE(); |
291 return NULL; | 291 return NULL; |
292 } | 292 } |
293 | 293 |
294 | 294 |
| 295 // Returns V8 version as a string. |
| 296 RUNTIME_FUNCTION(Runtime_GetV8Version) { |
| 297 HandleScope scope(isolate); |
| 298 DCHECK(args.length() == 0); |
| 299 |
| 300 const char* version_string = v8::V8::GetVersion(); |
| 301 |
| 302 return *isolate->factory()->NewStringFromAsciiChecked(version_string); |
| 303 } |
| 304 |
| 305 |
| 306 #ifdef DEBUG |
| 307 // ListNatives is ONLY used by the fuzz-natives.js in debug mode |
| 308 // Exclude the code in release mode. |
| 309 RUNTIME_FUNCTION(Runtime_ListNatives) { |
| 310 HandleScope scope(isolate); |
| 311 DCHECK(args.length() == 0); |
| 312 #define COUNT_ENTRY(Name, argc, ressize) +1 |
| 313 int entry_count = |
| 314 0 RUNTIME_FUNCTION_LIST(COUNT_ENTRY) INLINE_FUNCTION_LIST(COUNT_ENTRY) |
| 315 INLINE_OPTIMIZED_FUNCTION_LIST(COUNT_ENTRY); |
| 316 #undef COUNT_ENTRY |
| 317 Factory* factory = isolate->factory(); |
| 318 Handle<FixedArray> elements = factory->NewFixedArray(entry_count); |
| 319 int index = 0; |
| 320 bool inline_runtime_functions = false; |
| 321 #define ADD_ENTRY(Name, argc, ressize) \ |
| 322 { \ |
| 323 HandleScope inner(isolate); \ |
| 324 Handle<String> name; \ |
| 325 /* Inline runtime functions have an underscore in front of the name. */ \ |
| 326 if (inline_runtime_functions) { \ |
| 327 name = factory->NewStringFromStaticChars("_" #Name); \ |
| 328 } else { \ |
| 329 name = factory->NewStringFromStaticChars(#Name); \ |
| 330 } \ |
| 331 Handle<FixedArray> pair_elements = factory->NewFixedArray(2); \ |
| 332 pair_elements->set(0, *name); \ |
| 333 pair_elements->set(1, Smi::FromInt(argc)); \ |
| 334 Handle<JSArray> pair = factory->NewJSArrayWithElements(pair_elements); \ |
| 335 elements->set(index++, *pair); \ |
| 336 } |
| 337 inline_runtime_functions = false; |
| 338 RUNTIME_FUNCTION_LIST(ADD_ENTRY) |
| 339 INLINE_OPTIMIZED_FUNCTION_LIST(ADD_ENTRY) |
| 340 inline_runtime_functions = true; |
| 341 INLINE_FUNCTION_LIST(ADD_ENTRY) |
| 342 #undef ADD_ENTRY |
| 343 DCHECK_EQ(index, entry_count); |
| 344 Handle<JSArray> result = factory->NewJSArrayWithElements(elements); |
| 345 return *result; |
| 346 } |
| 347 #endif |
| 348 |
| 349 |
295 RUNTIME_FUNCTION(Runtime_HaveSameMap) { | 350 RUNTIME_FUNCTION(Runtime_HaveSameMap) { |
296 SealHandleScope shs(isolate); | 351 SealHandleScope shs(isolate); |
297 DCHECK(args.length() == 2); | 352 DCHECK(args.length() == 2); |
298 CONVERT_ARG_CHECKED(JSObject, obj1, 0); | 353 CONVERT_ARG_CHECKED(JSObject, obj1, 0); |
299 CONVERT_ARG_CHECKED(JSObject, obj2, 1); | 354 CONVERT_ARG_CHECKED(JSObject, obj2, 1); |
300 return isolate->heap()->ToBoolean(obj1->map() == obj2->map()); | 355 return isolate->heap()->ToBoolean(obj1->map() == obj2->map()); |
301 } | 356 } |
302 | 357 |
303 | 358 |
304 #define ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(Name) \ | 359 #define ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(Name) \ |
305 RUNTIME_FUNCTION(Runtime_Has##Name) { \ | 360 RUNTIME_FUNCTION(Runtime_Has##Name) { \ |
306 CONVERT_ARG_CHECKED(JSObject, obj, 0); \ | 361 CONVERT_ARG_CHECKED(JSObject, obj, 0); \ |
307 return isolate->heap()->ToBoolean(obj->Has##Name()); \ | 362 return isolate->heap()->ToBoolean(obj->Has##Name()); \ |
308 } | 363 } |
309 | 364 |
310 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastSmiElements) | 365 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastSmiElements) |
311 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastObjectElements) | 366 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastObjectElements) |
312 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastSmiOrObjectElements) | 367 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastSmiOrObjectElements) |
313 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastDoubleElements) | 368 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastDoubleElements) |
314 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastHoleyElements) | 369 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastHoleyElements) |
315 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(DictionaryElements) | 370 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(DictionaryElements) |
316 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(SloppyArgumentsElements) | 371 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(SloppyArgumentsElements) |
317 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalArrayElements) | 372 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalArrayElements) |
318 // Properties test sitting with elements tests - not fooling anyone. | 373 // Properties test sitting with elements tests - not fooling anyone. |
319 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastProperties) | 374 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastProperties) |
320 | 375 |
321 #undef ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION | 376 #undef ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION |
| 377 |
| 378 |
| 379 #define TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION(Type, type, TYPE, ctype, size) \ |
| 380 RUNTIME_FUNCTION(Runtime_HasExternal##Type##Elements) { \ |
| 381 CONVERT_ARG_CHECKED(JSObject, obj, 0); \ |
| 382 return isolate->heap()->ToBoolean(obj->HasExternal##Type##Elements()); \ |
| 383 } |
| 384 |
| 385 TYPED_ARRAYS(TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION) |
| 386 |
| 387 #undef TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION |
| 388 |
| 389 |
| 390 #define FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION(Type, type, TYPE, ctype, s) \ |
| 391 RUNTIME_FUNCTION(Runtime_HasFixed##Type##Elements) { \ |
| 392 CONVERT_ARG_CHECKED(JSObject, obj, 0); \ |
| 393 return isolate->heap()->ToBoolean(obj->HasFixed##Type##Elements()); \ |
| 394 } |
| 395 |
| 396 TYPED_ARRAYS(FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION) |
| 397 |
| 398 #undef FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION |
322 } | 399 } |
323 } // namespace v8::internal | 400 } // namespace v8::internal |
OLD | NEW |