aboutsummaryrefslogtreecommitdiff
path: root/src/interpreter/interpreter-intrinsics.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/interpreter/interpreter-intrinsics.cc')
-rw-r--r--src/interpreter/interpreter-intrinsics.cc139
1 files changed, 43 insertions, 96 deletions
diff --git a/src/interpreter/interpreter-intrinsics.cc b/src/interpreter/interpreter-intrinsics.cc
index b46ca878..78de42b6 100644
--- a/src/interpreter/interpreter-intrinsics.cc
+++ b/src/interpreter/interpreter-intrinsics.cc
@@ -5,6 +5,7 @@
#include "src/interpreter/interpreter-intrinsics.h"
#include "src/code-factory.h"
+#include "src/objects-inl.h"
namespace v8 {
namespace internal {
@@ -105,12 +106,8 @@ Node* IntrinsicsHelper::InvokeIntrinsic(Node* function_id, Node* context,
Node* IntrinsicsHelper::CompareInstanceType(Node* object, int type,
InstanceTypeCompareMode mode) {
- InterpreterAssembler::Variable return_value(assembler_,
- MachineRepresentation::kTagged);
Node* instance_type = __ LoadInstanceType(object);
- InterpreterAssembler::Label if_true(assembler_), if_false(assembler_),
- end(assembler_);
if (mode == kInstanceTypeEqual) {
return __ Word32Equal(instance_type, __ Int32Constant(type));
} else {
@@ -122,6 +119,7 @@ Node* IntrinsicsHelper::CompareInstanceType(Node* object, int type,
Node* IntrinsicsHelper::IsInstanceType(Node* input, int type) {
InterpreterAssembler::Variable return_value(assembler_,
MachineRepresentation::kTagged);
+ // TODO(ishell): Use Select here.
InterpreterAssembler::Label if_not_smi(assembler_), return_true(assembler_),
return_false(assembler_), end(assembler_);
Node* arg = __ LoadRegister(input);
@@ -148,6 +146,8 @@ Node* IntrinsicsHelper::IsInstanceType(Node* input, int type) {
Node* IntrinsicsHelper::IsJSReceiver(Node* input, Node* arg_count,
Node* context) {
+ // TODO(ishell): Use Select here.
+ // TODO(ishell): Use CSA::IsJSReceiverInstanceType here.
InterpreterAssembler::Variable return_value(assembler_,
MachineRepresentation::kTagged);
InterpreterAssembler::Label return_true(assembler_), return_false(assembler_),
@@ -185,16 +185,13 @@ 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) {
+ // TODO(ishell): Use SelectBooleanConstant here.
InterpreterAssembler::Variable return_value(assembler_,
MachineRepresentation::kTagged);
InterpreterAssembler::Label if_smi(assembler_), if_not_smi(assembler_),
@@ -222,14 +219,22 @@ Node* IntrinsicsHelper::IsSmi(Node* input, Node* arg_count, Node* context) {
Node* IntrinsicsHelper::IntrinsicAsStubCall(Node* args_reg, Node* context,
Callable const& callable) {
int param_count = callable.descriptor().GetParameterCount();
- Node** args = zone()->NewArray<Node*>(param_count + 1); // 1 for context
+ int input_count = param_count + 2; // +2 for target and context
+ Node** args = zone()->NewArray<Node*>(input_count);
+ int index = 0;
+ args[index++] = __ HeapConstant(callable.code());
for (int i = 0; i < param_count; i++) {
- args[i] = __ LoadRegister(args_reg);
+ args[index++] = __ LoadRegister(args_reg);
args_reg = __ NextRegister(args_reg);
}
- args[param_count] = context;
+ args[index++] = context;
+ return __ CallStubN(callable.descriptor(), 1, input_count, args);
+}
- return __ CallStubN(callable, args);
+Node* IntrinsicsHelper::CreateIterResultObject(Node* input, Node* arg_count,
+ Node* context) {
+ return IntrinsicAsStubCall(input, context,
+ CodeFactory::CreateIterResultObject(isolate()));
}
Node* IntrinsicsHelper::HasProperty(Node* input, Node* arg_count,
@@ -238,23 +243,6 @@ Node* IntrinsicsHelper::HasProperty(Node* input, Node* arg_count,
CodeFactory::HasProperty(isolate()));
}
-Node* IntrinsicsHelper::NewObject(Node* input, Node* arg_count, Node* context) {
- return IntrinsicAsStubCall(input, context,
- CodeFactory::FastNewObject(isolate()));
-}
-
-Node* IntrinsicsHelper::NumberToString(Node* input, Node* arg_count,
- Node* context) {
- return IntrinsicAsStubCall(input, context,
- CodeFactory::NumberToString(isolate()));
-}
-
-Node* IntrinsicsHelper::RegExpExec(Node* input, Node* arg_count,
- Node* context) {
- return IntrinsicAsStubCall(input, context,
- CodeFactory::RegExpExec(isolate()));
-}
-
Node* IntrinsicsHelper::SubString(Node* input, Node* arg_count, Node* context) {
return IntrinsicAsStubCall(input, context, CodeFactory::SubString(isolate()));
}
@@ -294,7 +282,7 @@ Node* IntrinsicsHelper::Call(Node* args_reg, Node* arg_count, Node* context) {
if (FLAG_debug_code) {
InterpreterAssembler::Label arg_count_positive(assembler_);
Node* comparison = __ Int32LessThan(target_args_count, __ Int32Constant(0));
- __ GotoUnless(comparison, &arg_count_positive);
+ __ GotoIfNot(comparison, &arg_count_positive);
__ Abort(kWrongArgumentCountForInvokeIntrinsic);
__ Goto(&arg_count_positive);
__ Bind(&arg_count_positive);
@@ -305,84 +293,43 @@ Node* IntrinsicsHelper::Call(Node* args_reg, Node* arg_count, Node* context) {
return result;
}
-Node* IntrinsicsHelper::ValueOf(Node* args_reg, Node* arg_count,
+Node* IntrinsicsHelper::ClassOf(Node* args_reg, Node* arg_count,
Node* context) {
+ Node* value = __ LoadRegister(args_reg);
+ return __ ClassOf(value);
+}
+
+Node* IntrinsicsHelper::CreateAsyncFromSyncIterator(Node* args_reg,
+ Node* arg_count,
+ Node* context) {
+ InterpreterAssembler::Label not_receiver(
+ assembler_, InterpreterAssembler::Label::kDeferred);
+ InterpreterAssembler::Label done(assembler_);
InterpreterAssembler::Variable return_value(assembler_,
MachineRepresentation::kTagged);
- InterpreterAssembler::Label done(assembler_);
- Node* object = __ LoadRegister(args_reg);
- return_value.Bind(object);
+ Node* sync_iterator = __ LoadRegister(args_reg);
- // If the object is a smi return the object.
- __ GotoIf(__ TaggedIsSmi(object), &done);
+ __ GotoIf(__ TaggedIsSmi(sync_iterator), &not_receiver);
+ __ GotoIfNot(__ IsJSReceiver(sync_iterator), &not_receiver);
- // If the object is not a value type, return the object.
- Node* condition =
- CompareInstanceType(object, JS_VALUE_TYPE, kInstanceTypeEqual);
- __ GotoUnless(condition, &done);
+ Node* const native_context = __ LoadNativeContext(context);
+ Node* const map = __ LoadContextElement(
+ native_context, Context::ASYNC_FROM_SYNC_ITERATOR_MAP_INDEX);
+ Node* const iterator = __ AllocateJSObjectFromMap(map);
- // If the object is a value type, return the value field.
- return_value.Bind(__ LoadObjectField(object, JSValue::kValueOffset));
- __ Goto(&done);
+ __ StoreObjectFieldNoWriteBarrier(
+ iterator, JSAsyncFromSyncIterator::kSyncIteratorOffset, sync_iterator);
- __ Bind(&done);
- return return_value.value();
-}
-
-Node* IntrinsicsHelper::ClassOf(Node* args_reg, Node* arg_count,
- Node* context) {
- InterpreterAssembler::Variable return_value(assembler_,
- MachineRepresentation::kTagged);
- InterpreterAssembler::Label done(assembler_), null(assembler_),
- function(assembler_), non_function_constructor(assembler_);
-
- Node* object = __ LoadRegister(args_reg);
-
- // If the object is not a JSReceiver, we return null.
- __ GotoIf(__ TaggedIsSmi(object), &null);
- STATIC_ASSERT(LAST_JS_RECEIVER_TYPE == LAST_TYPE);
- Node* is_js_receiver = CompareInstanceType(object, FIRST_JS_RECEIVER_TYPE,
- kInstanceTypeGreaterThanOrEqual);
- __ GotoUnless(is_js_receiver, &null);
-
- // Return 'Function' for JSFunction and JSBoundFunction objects.
- Node* is_function = CompareInstanceType(object, FIRST_FUNCTION_TYPE,
- kInstanceTypeGreaterThanOrEqual);
- STATIC_ASSERT(LAST_FUNCTION_TYPE == LAST_TYPE);
- __ GotoIf(is_function, &function);
-
- // Check if the constructor in the map is a JS function.
- Node* constructor = __ LoadMapConstructor(__ LoadMap(object));
- Node* constructor_is_js_function =
- CompareInstanceType(constructor, JS_FUNCTION_TYPE, kInstanceTypeEqual);
- __ GotoUnless(constructor_is_js_function, &non_function_constructor);
-
- // Grab the instance class name from the constructor function.
- Node* shared =
- __ LoadObjectField(constructor, JSFunction::kSharedFunctionInfoOffset);
- return_value.Bind(
- __ LoadObjectField(shared, SharedFunctionInfo::kInstanceClassNameOffset));
+ return_value.Bind(iterator);
__ Goto(&done);
- // Non-JS objects have class null.
- __ Bind(&null);
+ __ Bind(&not_receiver);
{
- return_value.Bind(__ LoadRoot(Heap::kNullValueRootIndex));
- __ Goto(&done);
- }
+ return_value.Bind(
+ __ CallRuntime(Runtime::kThrowSymbolIteratorInvalid, context));
- // Functions have class 'Function'.
- __ Bind(&function);
- {
- return_value.Bind(__ LoadRoot(Heap::kFunction_stringRootIndex));
- __ Goto(&done);
- }
-
- // Objects with a non-function constructor have class 'Object'.
- __ Bind(&non_function_constructor);
- {
- return_value.Bind(__ LoadRoot(Heap::kObject_stringRootIndex));
+ // Unreachable due to the Throw in runtime call.
__ Goto(&done);
}