blob: cc15d0e18310cc65faa0b186cf08a245bd8d082e [file] [log] [blame]
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001// 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
3// found in the LICENSE file.
4
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00005#include "src/runtime/runtime-utils.h"
Emily Bernierd0a1eb72015-03-24 16:35:39 -04006
7#include "src/arguments.h"
8#include "src/deoptimizer.h"
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00009#include "src/frames-inl.h"
10#include "src/full-codegen/full-codegen.h"
Ben Murdochc5610432016-08-08 18:44:38 +010011#include "src/isolate-inl.h"
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000012#include "src/snapshot/natives.h"
Emily Bernierd0a1eb72015-03-24 16:35:39 -040013
14namespace v8 {
15namespace internal {
16
17RUNTIME_FUNCTION(Runtime_DeoptimizeFunction) {
18 HandleScope scope(isolate);
19 DCHECK(args.length() == 1);
Ben Murdochc5610432016-08-08 18:44:38 +010020
21 // This function is used by fuzzers to get coverage in compiler.
22 // Ignore calls on non-function objects to avoid runtime errors.
23 CONVERT_ARG_HANDLE_CHECKED(Object, function_object, 0);
24 // If it is not a JSFunction, just return.
25 if (!function_object->IsJSFunction()) {
26 return isolate->heap()->undefined_value();
27 }
28 Handle<JSFunction> function = Handle<JSFunction>::cast(function_object);
29
Emily Bernierd0a1eb72015-03-24 16:35:39 -040030 if (!function->IsOptimized()) return isolate->heap()->undefined_value();
31
32 // TODO(turbofan): Deoptimization is not supported yet.
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000033 if (function->code()->is_turbofanned() &&
34 function->shared()->asm_function() && !FLAG_turbo_asm_deoptimization) {
35 return isolate->heap()->undefined_value();
36 }
37
38 Deoptimizer::DeoptimizeFunction(*function);
39
40 return isolate->heap()->undefined_value();
41}
42
43
44RUNTIME_FUNCTION(Runtime_DeoptimizeNow) {
45 HandleScope scope(isolate);
46 DCHECK(args.length() == 0);
47
48 Handle<JSFunction> function;
49
50 // If the argument is 'undefined', deoptimize the topmost
51 // function.
52 JavaScriptFrameIterator it(isolate);
53 while (!it.done()) {
54 if (it.frame()->is_java_script()) {
55 function = Handle<JSFunction>(it.frame()->function());
56 break;
57 }
58 }
59 if (function.is_null()) return isolate->heap()->undefined_value();
60
61 if (!function->IsOptimized()) return isolate->heap()->undefined_value();
62
63 // TODO(turbofan): Deoptimization is not supported yet.
64 if (function->code()->is_turbofanned() &&
65 function->shared()->asm_function() && !FLAG_turbo_asm_deoptimization) {
Emily Bernierd0a1eb72015-03-24 16:35:39 -040066 return isolate->heap()->undefined_value();
67 }
68
69 Deoptimizer::DeoptimizeFunction(*function);
70
71 return isolate->heap()->undefined_value();
72}
73
74
75RUNTIME_FUNCTION(Runtime_RunningInSimulator) {
76 SealHandleScope shs(isolate);
77 DCHECK(args.length() == 0);
78#if defined(USE_SIMULATOR)
79 return isolate->heap()->true_value();
80#else
81 return isolate->heap()->false_value();
82#endif
83}
84
85
86RUNTIME_FUNCTION(Runtime_IsConcurrentRecompilationSupported) {
87 SealHandleScope shs(isolate);
88 DCHECK(args.length() == 0);
89 return isolate->heap()->ToBoolean(
90 isolate->concurrent_recompilation_enabled());
91}
92
93
94RUNTIME_FUNCTION(Runtime_OptimizeFunctionOnNextCall) {
95 HandleScope scope(isolate);
96 RUNTIME_ASSERT(args.length() == 1 || args.length() == 2);
Ben Murdochc5610432016-08-08 18:44:38 +010097
98 // This function is used by fuzzers to get coverage for optimizations
99 // in compiler. Ignore calls on non-function objects to avoid runtime errors.
100 CONVERT_ARG_HANDLE_CHECKED(Object, function_object, 0);
101 // If it is not a JSFunction, just return.
102 if (!function_object->IsJSFunction()) {
103 return isolate->heap()->undefined_value();
104 }
105 Handle<JSFunction> function = Handle<JSFunction>::cast(function_object);
106
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000107 // The following assertion was lifted from the DCHECK inside
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400108 // JSFunction::MarkForOptimization().
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400109 RUNTIME_ASSERT(function->shared()->allows_lazy_compilation() ||
110 (function->code()->kind() == Code::FUNCTION &&
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000111 !function->shared()->optimization_disabled()));
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400112
113 // If the function is already optimized, just return.
114 if (function->IsOptimized()) return isolate->heap()->undefined_value();
115
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400116 function->MarkForOptimization();
117
118 Code* unoptimized = function->shared()->code();
119 if (args.length() == 2 && unoptimized->kind() == Code::FUNCTION) {
120 CONVERT_ARG_HANDLE_CHECKED(String, type, 1);
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000121 if (type->IsOneByteEqualTo(STATIC_CHAR_VECTOR("concurrent")) &&
122 isolate->concurrent_recompilation_enabled()) {
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400123 function->AttemptConcurrentOptimization();
124 }
125 }
126
127 return isolate->heap()->undefined_value();
128}
129
130
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000131RUNTIME_FUNCTION(Runtime_OptimizeOsr) {
132 HandleScope scope(isolate);
133 RUNTIME_ASSERT(args.length() == 0 || args.length() == 1);
134 Handle<JSFunction> function = Handle<JSFunction>::null();
135
136 if (args.length() == 0) {
137 // Find the JavaScript function on the top of the stack.
138 JavaScriptFrameIterator it(isolate);
139 while (!it.done()) {
140 if (it.frame()->is_java_script()) {
141 function = Handle<JSFunction>(it.frame()->function());
142 break;
143 }
144 }
145 if (function.is_null()) return isolate->heap()->undefined_value();
146 } else {
147 // Function was passed as an argument.
148 CONVERT_ARG_HANDLE_CHECKED(JSFunction, arg, 0);
149 function = arg;
150 }
151
152 // The following assertion was lifted from the DCHECK inside
153 // JSFunction::MarkForOptimization().
154 RUNTIME_ASSERT(function->shared()->allows_lazy_compilation() ||
155 !function->shared()->optimization_disabled());
156
Ben Murdochc5610432016-08-08 18:44:38 +0100157 // If function is interpreted, just return. OSR is not supported.
158 // TODO(4764): Remove this check when OSR is enabled in the interpreter.
159 if (function->shared()->HasBytecodeArray()) {
160 return isolate->heap()->undefined_value();
161 }
162
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000163 // If the function is already optimized, just return.
164 if (function->IsOptimized()) return isolate->heap()->undefined_value();
165
166 Code* unoptimized = function->shared()->code();
167 if (unoptimized->kind() == Code::FUNCTION) {
168 DCHECK(BackEdgeTable::Verify(isolate, unoptimized));
169 isolate->runtime_profiler()->AttemptOnStackReplacement(
170 *function, Code::kMaxLoopNestingMarker);
171 }
172
173 return isolate->heap()->undefined_value();
174}
175
176
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400177RUNTIME_FUNCTION(Runtime_NeverOptimizeFunction) {
178 HandleScope scope(isolate);
179 DCHECK(args.length() == 1);
180 CONVERT_ARG_CHECKED(JSFunction, function, 0);
Ben Murdochc5610432016-08-08 18:44:38 +0100181 function->shared()->set_disable_optimization_reason(
182 kOptimizationDisabledForTest);
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400183 function->shared()->set_optimization_disabled(true);
184 return isolate->heap()->undefined_value();
185}
186
187
188RUNTIME_FUNCTION(Runtime_GetOptimizationStatus) {
189 HandleScope scope(isolate);
190 RUNTIME_ASSERT(args.length() == 1 || args.length() == 2);
191 if (!isolate->use_crankshaft()) {
192 return Smi::FromInt(4); // 4 == "never".
193 }
194 bool sync_with_compiler_thread = true;
195 if (args.length() == 2) {
196 CONVERT_ARG_HANDLE_CHECKED(String, sync, 1);
197 if (sync->IsOneByteEqualTo(STATIC_CHAR_VECTOR("no sync"))) {
198 sync_with_compiler_thread = false;
199 }
200 }
201 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
202 if (isolate->concurrent_recompilation_enabled() &&
203 sync_with_compiler_thread) {
204 while (function->IsInOptimizationQueue()) {
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000205 isolate->optimizing_compile_dispatcher()->InstallOptimizedFunctions();
206 base::OS::Sleep(base::TimeDelta::FromMilliseconds(50));
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400207 }
208 }
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000209 if (FLAG_always_opt || FLAG_prepare_always_opt) {
210 // With --always-opt, optimization status expectations might not
211 // match up, so just return a sentinel.
212 return Smi::FromInt(3); // 3 == "always".
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400213 }
214 if (FLAG_deopt_every_n_times) {
215 return Smi::FromInt(6); // 6 == "maybe deopted".
216 }
217 if (function->IsOptimized() && function->code()->is_turbofanned()) {
218 return Smi::FromInt(7); // 7 == "TurboFan compiler".
219 }
220 return function->IsOptimized() ? Smi::FromInt(1) // 1 == "yes".
221 : Smi::FromInt(2); // 2 == "no".
222}
223
224
225RUNTIME_FUNCTION(Runtime_UnblockConcurrentRecompilation) {
226 DCHECK(args.length() == 0);
227 RUNTIME_ASSERT(FLAG_block_concurrent_recompilation);
228 RUNTIME_ASSERT(isolate->concurrent_recompilation_enabled());
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000229 isolate->optimizing_compile_dispatcher()->Unblock();
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400230 return isolate->heap()->undefined_value();
231}
232
233
234RUNTIME_FUNCTION(Runtime_GetOptimizationCount) {
235 HandleScope scope(isolate);
236 DCHECK(args.length() == 1);
237 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
238 return Smi::FromInt(function->shared()->opt_count());
239}
240
241
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000242RUNTIME_FUNCTION(Runtime_GetUndetectable) {
243 HandleScope scope(isolate);
244 DCHECK(args.length() == 0);
245 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate);
246
247 Local<v8::ObjectTemplate> desc = v8::ObjectTemplate::New(v8_isolate);
248 desc->MarkAsUndetectable();
249 Local<v8::Object> obj;
250 if (!desc->NewInstance(v8_isolate->GetCurrentContext()).ToLocal(&obj)) {
251 return nullptr;
252 }
253 return *Utils::OpenHandle(*obj);
254}
255
256
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400257RUNTIME_FUNCTION(Runtime_ClearFunctionTypeFeedback) {
258 HandleScope scope(isolate);
259 DCHECK(args.length() == 1);
260 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
261 function->shared()->ClearTypeFeedbackInfo();
262 Code* unoptimized = function->shared()->code();
263 if (unoptimized->kind() == Code::FUNCTION) {
264 unoptimized->ClearInlineCaches();
265 }
266 return isolate->heap()->undefined_value();
267}
268
269
270RUNTIME_FUNCTION(Runtime_NotifyContextDisposed) {
271 HandleScope scope(isolate);
272 DCHECK(args.length() == 0);
273 isolate->heap()->NotifyContextDisposed(true);
274 return isolate->heap()->undefined_value();
275}
276
277
278RUNTIME_FUNCTION(Runtime_SetAllocationTimeout) {
279 SealHandleScope shs(isolate);
280 DCHECK(args.length() == 2 || args.length() == 3);
281#ifdef DEBUG
282 CONVERT_SMI_ARG_CHECKED(interval, 0);
283 CONVERT_SMI_ARG_CHECKED(timeout, 1);
284 isolate->heap()->set_allocation_timeout(timeout);
285 FLAG_gc_interval = interval;
286 if (args.length() == 3) {
287 // Enable/disable inline allocation if requested.
288 CONVERT_BOOLEAN_ARG_CHECKED(inline_allocation, 2);
289 if (inline_allocation) {
290 isolate->heap()->EnableInlineAllocation();
291 } else {
292 isolate->heap()->DisableInlineAllocation();
293 }
294 }
295#endif
296 return isolate->heap()->undefined_value();
297}
298
299
300RUNTIME_FUNCTION(Runtime_DebugPrint) {
301 SealHandleScope shs(isolate);
302 DCHECK(args.length() == 1);
303
304 OFStream os(stdout);
305#ifdef DEBUG
306 if (args[0]->IsString()) {
307 // If we have a string, assume it's a code "marker"
308 // and print some interesting cpu debugging info.
309 JavaScriptFrameIterator it(isolate);
310 JavaScriptFrame* frame = it.frame();
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000311 os << "fp = " << static_cast<void*>(frame->fp())
312 << ", sp = " << static_cast<void*>(frame->sp())
313 << ", caller_sp = " << static_cast<void*>(frame->caller_sp()) << ": ";
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400314 } else {
315 os << "DebugPrint: ";
316 }
317 args[0]->Print(os);
318 if (args[0]->IsHeapObject()) {
319 os << "\n";
320 HeapObject::cast(args[0])->map()->Print(os);
321 }
322#else
323 // ShortPrint is available in release mode. Print is not.
324 os << Brief(args[0]);
325#endif
326 os << std::endl;
327
328 return args[0]; // return TOS
329}
330
331
332RUNTIME_FUNCTION(Runtime_DebugTrace) {
333 SealHandleScope shs(isolate);
334 DCHECK(args.length() == 0);
335 isolate->PrintStack(stdout);
336 return isolate->heap()->undefined_value();
337}
338
339
340// This will not allocate (flatten the string), but it may run
341// very slowly for very deeply nested ConsStrings. For debugging use only.
342RUNTIME_FUNCTION(Runtime_GlobalPrint) {
343 SealHandleScope shs(isolate);
344 DCHECK(args.length() == 1);
345
346 CONVERT_ARG_CHECKED(String, string, 0);
347 StringCharacterStream stream(string);
348 while (stream.HasMore()) {
349 uint16_t character = stream.GetNext();
350 PrintF("%c", character);
351 }
352 return string;
353}
354
355
356RUNTIME_FUNCTION(Runtime_SystemBreak) {
357 // The code below doesn't create handles, but when breaking here in GDB
358 // having a handle scope might be useful.
359 HandleScope scope(isolate);
360 DCHECK(args.length() == 0);
361 base::OS::DebugBreak();
362 return isolate->heap()->undefined_value();
363}
364
365
366// Sets a v8 flag.
367RUNTIME_FUNCTION(Runtime_SetFlags) {
368 SealHandleScope shs(isolate);
369 DCHECK(args.length() == 1);
370 CONVERT_ARG_CHECKED(String, arg, 0);
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000371 base::SmartArrayPointer<char> flags =
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400372 arg->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
373 FlagList::SetFlagsFromString(flags.get(), StrLength(flags.get()));
374 return isolate->heap()->undefined_value();
375}
376
377
378RUNTIME_FUNCTION(Runtime_Abort) {
379 SealHandleScope shs(isolate);
380 DCHECK(args.length() == 1);
381 CONVERT_SMI_ARG_CHECKED(message_id, 0);
382 const char* message =
383 GetBailoutReason(static_cast<BailoutReason>(message_id));
384 base::OS::PrintError("abort: %s\n", message);
385 isolate->PrintStack(stderr);
386 base::OS::Abort();
387 UNREACHABLE();
388 return NULL;
389}
390
391
392RUNTIME_FUNCTION(Runtime_AbortJS) {
393 HandleScope scope(isolate);
394 DCHECK(args.length() == 1);
395 CONVERT_ARG_HANDLE_CHECKED(String, message, 0);
396 base::OS::PrintError("abort: %s\n", message->ToCString().get());
397 isolate->PrintStack(stderr);
398 base::OS::Abort();
399 UNREACHABLE();
400 return NULL;
401}
402
403
404RUNTIME_FUNCTION(Runtime_NativeScriptsCount) {
405 DCHECK(args.length() == 0);
Ben Murdoch097c5b22016-05-18 11:27:45 +0100406 return Smi::FromInt(Natives::GetBuiltinsCount());
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400407}
408
409
410// Returns V8 version as a string.
411RUNTIME_FUNCTION(Runtime_GetV8Version) {
412 HandleScope scope(isolate);
413 DCHECK(args.length() == 0);
414
415 const char* version_string = v8::V8::GetVersion();
416
417 return *isolate->factory()->NewStringFromAsciiChecked(version_string);
418}
419
420
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000421RUNTIME_FUNCTION(Runtime_DisassembleFunction) {
422 HandleScope scope(isolate);
423#ifdef DEBUG
424 DCHECK(args.length() == 1);
425 // Get the function and make sure it is compiled.
426 CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0);
Ben Murdochda12d292016-06-02 14:46:10 +0100427 if (!Compiler::Compile(func, Compiler::KEEP_EXCEPTION)) {
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000428 return isolate->heap()->exception();
429 }
430 OFStream os(stdout);
431 func->code()->Print(os);
432 os << std::endl;
433#endif // DEBUG
434 return isolate->heap()->undefined_value();
435}
436
Ben Murdoch097c5b22016-05-18 11:27:45 +0100437namespace {
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000438
Ben Murdoch097c5b22016-05-18 11:27:45 +0100439int StackSize(Isolate* isolate) {
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400440 int n = 0;
441 for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) n++;
442 return n;
443}
444
Ben Murdoch097c5b22016-05-18 11:27:45 +0100445void PrintIndentation(Isolate* isolate) {
446 const int nmax = 80;
447 int n = StackSize(isolate);
448 if (n <= nmax) {
449 PrintF("%4d:%*s", n, n, "");
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400450 } else {
Ben Murdoch097c5b22016-05-18 11:27:45 +0100451 PrintF("%4d:%*s", n, nmax, "...");
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400452 }
453}
454
Ben Murdoch097c5b22016-05-18 11:27:45 +0100455} // namespace
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400456
457RUNTIME_FUNCTION(Runtime_TraceEnter) {
458 SealHandleScope shs(isolate);
Ben Murdoch097c5b22016-05-18 11:27:45 +0100459 DCHECK_EQ(0, args.length());
460 PrintIndentation(isolate);
461 JavaScriptFrame::PrintTop(isolate, stdout, true, false);
462 PrintF(" {\n");
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400463 return isolate->heap()->undefined_value();
464}
465
466
467RUNTIME_FUNCTION(Runtime_TraceExit) {
468 SealHandleScope shs(isolate);
Ben Murdoch097c5b22016-05-18 11:27:45 +0100469 DCHECK_EQ(1, args.length());
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400470 CONVERT_ARG_CHECKED(Object, obj, 0);
Ben Murdoch097c5b22016-05-18 11:27:45 +0100471 PrintIndentation(isolate);
472 PrintF("} -> ");
473 obj->ShortPrint();
474 PrintF("\n");
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400475 return obj; // return TOS
476}
477
Ben Murdoch097c5b22016-05-18 11:27:45 +0100478RUNTIME_FUNCTION(Runtime_TraceTailCall) {
479 SealHandleScope shs(isolate);
480 DCHECK_EQ(0, args.length());
481 PrintIndentation(isolate);
482 PrintF("} -> tail call ->\n");
483 return isolate->heap()->undefined_value();
484}
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400485
Ben Murdochc5610432016-08-08 18:44:38 +0100486RUNTIME_FUNCTION(Runtime_GetExceptionDetails) {
487 HandleScope shs(isolate);
488 DCHECK(args.length() == 1);
489 CONVERT_ARG_HANDLE_CHECKED(JSObject, exception_obj, 0);
490
491 Factory* factory = isolate->factory();
492 Handle<JSMessageObject> message_obj =
493 isolate->CreateMessage(exception_obj, nullptr);
494
495 Handle<JSObject> message = factory->NewJSObject(isolate->object_function());
496
497 Handle<String> key;
498 Handle<Object> value;
499
500 key = factory->NewStringFromAsciiChecked("start_pos");
501 value = handle(Smi::FromInt(message_obj->start_position()), isolate);
502 JSObject::SetProperty(message, key, value, STRICT).Assert();
503
504 key = factory->NewStringFromAsciiChecked("end_pos");
505 value = handle(Smi::FromInt(message_obj->end_position()), isolate);
506 JSObject::SetProperty(message, key, value, STRICT).Assert();
507
508 return *message;
509}
510
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400511RUNTIME_FUNCTION(Runtime_HaveSameMap) {
512 SealHandleScope shs(isolate);
513 DCHECK(args.length() == 2);
514 CONVERT_ARG_CHECKED(JSObject, obj1, 0);
515 CONVERT_ARG_CHECKED(JSObject, obj2, 1);
516 return isolate->heap()->ToBoolean(obj1->map() == obj2->map());
517}
518
519
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000520RUNTIME_FUNCTION(Runtime_InNewSpace) {
521 SealHandleScope shs(isolate);
522 DCHECK(args.length() == 1);
523 CONVERT_ARG_CHECKED(Object, obj, 0);
524 return isolate->heap()->ToBoolean(isolate->heap()->InNewSpace(obj));
525}
526
527
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400528#define ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(Name) \
529 RUNTIME_FUNCTION(Runtime_Has##Name) { \
530 CONVERT_ARG_CHECKED(JSObject, obj, 0); \
531 return isolate->heap()->ToBoolean(obj->Has##Name()); \
532 }
533
534ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastSmiElements)
535ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastObjectElements)
536ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastSmiOrObjectElements)
537ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastDoubleElements)
538ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastHoleyElements)
539ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(DictionaryElements)
540ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(SloppyArgumentsElements)
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000541ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FixedTypedArrayElements)
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400542// Properties test sitting with elements tests - not fooling anyone.
543ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastProperties)
544
545#undef ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION
546
547
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400548#define FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION(Type, type, TYPE, ctype, s) \
549 RUNTIME_FUNCTION(Runtime_HasFixed##Type##Elements) { \
550 CONVERT_ARG_CHECKED(JSObject, obj, 0); \
551 return isolate->heap()->ToBoolean(obj->HasFixed##Type##Elements()); \
552 }
553
554TYPED_ARRAYS(FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION)
555
556#undef FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION
Ben Murdochda12d292016-06-02 14:46:10 +0100557
558
559RUNTIME_FUNCTION(Runtime_SpeciesProtector) {
560 SealHandleScope shs(isolate);
561 DCHECK_EQ(0, args.length());
562 return isolate->heap()->ToBoolean(isolate->IsArraySpeciesLookupChainIntact());
563}
564
565
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000566} // namespace internal
567} // namespace v8