From 29308cf0e5674c547cb011fe5856a6f286660fff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Z=C3=BCnd?= Date: Tue, 10 Apr 2018 10:47:00 +0200 Subject: [PATCH] Add boolean runtime checks for different element kinds. This will be used for Array.p.sort benchmarks to ensure that the arrays will have the correct element kind. R=cbruni@chromium.org, jgruber@chromium.org Bug: v8:7382 Change-Id: I4fe58d97d7f18fd193d4432964cf6b4f5335e0e7 Reviewed-on: https://chromium-review.googlesource.com/1004754 Commit-Queue: Jakob Gruber Reviewed-by: Jakob Gruber Cr-Commit-Position: refs/heads/master@{#52511} --- src/runtime/runtime-object.cc | 18 ++++++++++++++++++ src/runtime/runtime.h | 6 ++++++ 2 files changed, 24 insertions(+) diff --git a/src/runtime/runtime-object.cc b/src/runtime/runtime-object.cc index b68315f286..230c929745 100644 --- a/src/runtime/runtime-object.cc +++ b/src/runtime/runtime-object.cc @@ -874,6 +874,24 @@ RUNTIME_FUNCTION(Runtime_HasFastPackedElements) { IsFastPackedElementsKind(obj->map()->elements_kind())); } +#define RUNTIME_FUNCTION_CHECK_ELEMENT_KIND(Name, Kind) \ + RUNTIME_FUNCTION(Runtime_##Name) { \ + SealHandleScope shs(isolate); \ + DCHECK_EQ(1, args.length()); \ + CONVERT_ARG_CHECKED(HeapObject, obj, 0); \ + return isolate->heap()->ToBoolean(obj->map()->elements_kind() == Kind); \ + } + +RUNTIME_FUNCTION_CHECK_ELEMENT_KIND(HasPackedSmiElements, PACKED_SMI_ELEMENTS) +RUNTIME_FUNCTION_CHECK_ELEMENT_KIND(HasPackedDoubleElements, + PACKED_DOUBLE_ELEMENTS) +RUNTIME_FUNCTION_CHECK_ELEMENT_KIND(HasPackedObjectElements, PACKED_ELEMENTS) +RUNTIME_FUNCTION_CHECK_ELEMENT_KIND(HasHoleySmiElements, HOLEY_SMI_ELEMENTS) +RUNTIME_FUNCTION_CHECK_ELEMENT_KIND(HasHoleyDoubleElements, + HOLEY_DOUBLE_ELEMENTS) +RUNTIME_FUNCTION_CHECK_ELEMENT_KIND(HasHoleyObjectElements, HOLEY_ELEMENTS) + +#undef RUNTIME_FUNCTION_CHECK_ELEMENT_KIND RUNTIME_FUNCTION(Runtime_ValueOf) { SealHandleScope shs(isolate); diff --git a/src/runtime/runtime.h b/src/runtime/runtime.h index 5fc0c472ba..e19367c5b1 100644 --- a/src/runtime/runtime.h +++ b/src/runtime/runtime.h @@ -382,6 +382,12 @@ namespace internal { F(GetOwnPropertyKeys, 2, 1) \ F(GetProperty, 2, 1) \ F(GetPrototype, 1, 1) \ + F(HasPackedSmiElements, 1, 1) \ + F(HasPackedDoubleElements, 1, 1) \ + F(HasPackedObjectElements, 1, 1) \ + F(HasHoleySmiElements, 1, 1) \ + F(HasHoleyDoubleElements, 1, 1) \ + F(HasHoleyObjectElements, 1, 1) \ F(HasFastPackedElements, 1, 1) \ F(HasInPrototypeChain, 2, 1) \ F(HasProperty, 2, 1) \