Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(294)

Unified Diff: src/interpreter/interpreter-intrinsics.cc

Issue 2034493002: [Interpreter] Add intrinsics for Is<Type> calls. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add non-smi int to test Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/interpreter/interpreter-intrinsics.h ('k') | test/cctest/interpreter/test-interpreter-intrinsics.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/interpreter/interpreter-intrinsics.cc
diff --git a/src/interpreter/interpreter-intrinsics.cc b/src/interpreter/interpreter-intrinsics.cc
index 7a4abd0fcaf394e1e1cd08507e61aa8c074593c4..f961b3b29ad170c0497d736933b8066a86a32e6f 100644
--- a/src/interpreter/interpreter-intrinsics.cc
+++ b/src/interpreter/interpreter-intrinsics.cc
@@ -58,9 +58,11 @@ Node* IntrinsicsHelper::InvokeIntrinsic(Node* function_id, Node* context,
#undef HANDLE_CASE
__ Bind(&abort);
- __ Abort(BailoutReason::kUnexpectedFunctionIDForInvokeIntrinsic);
- result.Bind(__ UndefinedConstant());
- __ Goto(&end);
+ {
+ __ Abort(BailoutReason::kUnexpectedFunctionIDForInvokeIntrinsic);
+ result.Bind(__ UndefinedConstant());
+ __ Goto(&end);
+ }
__ Bind(&end);
return result.value();
@@ -85,12 +87,40 @@ Node* IntrinsicsHelper::CompareInstanceType(Node* map, int type,
__ Branch(condition, &if_true, &if_false);
__ Bind(&if_true);
- return_value.Bind(__ BooleanConstant(true));
- __ Goto(&end);
+ {
+ return_value.Bind(__ BooleanConstant(true));
+ __ Goto(&end);
+ }
__ Bind(&if_false);
- return_value.Bind(__ BooleanConstant(false));
- __ Goto(&end);
+ {
+ return_value.Bind(__ BooleanConstant(false));
+ __ Goto(&end);
+ }
+
+ __ Bind(&end);
+ return return_value.value();
+}
+
+Node* IntrinsicsHelper::IsInstanceType(Node* input, int type) {
+ InterpreterAssembler::Variable return_value(assembler_,
+ MachineRepresentation::kTagged);
+ InterpreterAssembler::Label if_smi(assembler_), if_not_smi(assembler_),
+ end(assembler_);
+ Node* arg = __ LoadRegister(input);
+ __ Branch(__ WordIsSmi(arg), &if_smi, &if_not_smi);
+
+ __ Bind(&if_smi);
+ {
+ return_value.Bind(__ BooleanConstant(false));
+ __ Goto(&end);
+ }
+
+ __ Bind(&if_not_smi);
+ {
+ return_value.Bind(CompareInstanceType(arg, type, kInstanceTypeEqual));
+ __ Goto(&end);
+ }
__ Bind(&end);
return return_value.value();
@@ -100,43 +130,67 @@ Node* IntrinsicsHelper::IsJSReceiver(Node* input, Node* arg_count,
Node* context) {
InterpreterAssembler::Variable return_value(assembler_,
MachineRepresentation::kTagged);
-
InterpreterAssembler::Label if_smi(assembler_), if_not_smi(assembler_),
end(assembler_);
- Node* arg = __ LoadRegister(input);
+ Node* arg = __ LoadRegister(input);
__ Branch(__ WordIsSmi(arg), &if_smi, &if_not_smi);
+
__ Bind(&if_smi);
- return_value.Bind(__ BooleanConstant(false));
- __ Goto(&end);
+ {
+ return_value.Bind(__ BooleanConstant(false));
+ __ Goto(&end);
+ }
__ Bind(&if_not_smi);
- STATIC_ASSERT(LAST_TYPE == LAST_JS_RECEIVER_TYPE);
- return_value.Bind(CompareInstanceType(arg, FIRST_JS_RECEIVER_TYPE,
- kInstanceTypeGreaterThanOrEqual));
- __ Goto(&end);
+ {
+ STATIC_ASSERT(LAST_TYPE == LAST_JS_RECEIVER_TYPE);
+ return_value.Bind(CompareInstanceType(arg, FIRST_JS_RECEIVER_TYPE,
+ kInstanceTypeGreaterThanOrEqual));
+ __ Goto(&end);
+ }
__ Bind(&end);
return return_value.value();
}
Node* IntrinsicsHelper::IsArray(Node* input, Node* arg_count, Node* context) {
+ return IsInstanceType(input, JS_ARRAY_TYPE);
+}
+
+Node* IntrinsicsHelper::IsJSProxy(Node* input, Node* arg_count, Node* context) {
+ return IsInstanceType(input, JS_PROXY_TYPE);
+}
+
+Node* IntrinsicsHelper::IsRegExp(Node* input, Node* arg_count, Node* context) {
+ return IsInstanceType(input, JS_REGEXP_TYPE);
+}
+
+Node* IntrinsicsHelper::IsTypedArray(Node* input, Node* arg_count,
+ Node* context) {
+ return IsInstanceType(input, JS_TYPED_ARRAY_TYPE);
+}
+
+Node* IntrinsicsHelper::IsSmi(Node* input, Node* arg_count, Node* context) {
InterpreterAssembler::Variable return_value(assembler_,
MachineRepresentation::kTagged);
-
InterpreterAssembler::Label if_smi(assembler_), if_not_smi(assembler_),
end(assembler_);
+
Node* arg = __ LoadRegister(input);
__ Branch(__ WordIsSmi(arg), &if_smi, &if_not_smi);
__ Bind(&if_smi);
- return_value.Bind(__ BooleanConstant(false));
- __ Goto(&end);
+ {
+ return_value.Bind(__ BooleanConstant(true));
+ __ Goto(&end);
+ }
__ Bind(&if_not_smi);
- return_value.Bind(
- CompareInstanceType(arg, JS_ARRAY_TYPE, kInstanceTypeEqual));
- __ Goto(&end);
+ {
+ return_value.Bind(__ BooleanConstant(false));
+ __ Goto(&end);
+ }
__ Bind(&end);
return return_value.value();
« no previous file with comments | « src/interpreter/interpreter-intrinsics.h ('k') | test/cctest/interpreter/test-interpreter-intrinsics.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698