summaryrefslogtreecommitdiff
path: root/deps/v8/src/compiler/node-properties.cc
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/compiler/node-properties.cc')
-rw-r--r--deps/v8/src/compiler/node-properties.cc105
1 files changed, 105 insertions, 0 deletions
diff --git a/deps/v8/src/compiler/node-properties.cc b/deps/v8/src/compiler/node-properties.cc
index 4fb4aa487c..cb6c3c43d8 100644
--- a/deps/v8/src/compiler/node-properties.cc
+++ b/deps/v8/src/compiler/node-properties.cc
@@ -4,6 +4,7 @@
#include "src/compiler/common-operator.h"
#include "src/compiler/graph.h"
+#include "src/compiler/linkage.h"
#include "src/compiler/node-properties.h"
#include "src/compiler/operator-properties.h"
#include "src/compiler/verifier.h"
@@ -138,6 +139,17 @@ void NodeProperties::ReplaceValueInput(Node* node, Node* value, int index) {
// static
+void NodeProperties::ReplaceValueInputs(Node* node, Node* value) {
+ int value_input_count = node->op()->ValueInputCount();
+ DCHECK_LE(1, value_input_count);
+ node->ReplaceInput(0, value);
+ while (--value_input_count > 0) {
+ node->RemoveInput(value_input_count);
+ }
+}
+
+
+// static
void NodeProperties::ReplaceContextInput(Node* node, Node* context) {
node->ReplaceInput(FirstContextIndex(node), context);
}
@@ -177,6 +189,15 @@ void NodeProperties::RemoveNonValueInputs(Node* node) {
}
+// static
+void NodeProperties::RemoveValueInputs(Node* node) {
+ int value_input_count = node->op()->ValueInputCount();
+ while (--value_input_count >= 0) {
+ node->RemoveInput(value_input_count);
+ }
+}
+
+
void NodeProperties::MergeControlToEnd(Graph* graph,
CommonOperatorBuilder* common,
Node* node) {
@@ -284,6 +305,90 @@ void NodeProperties::CollectControlProjections(Node* node, Node** projections,
// static
+MaybeHandle<Context> NodeProperties::GetSpecializationContext(
+ Node* node, MaybeHandle<Context> context) {
+ switch (node->opcode()) {
+ case IrOpcode::kHeapConstant:
+ return Handle<Context>::cast(OpParameter<Handle<HeapObject>>(node));
+ case IrOpcode::kParameter: {
+ Node* const start = NodeProperties::GetValueInput(node, 0);
+ DCHECK_EQ(IrOpcode::kStart, start->opcode());
+ int const index = ParameterIndexOf(node->op());
+ // The context is always the last parameter to a JavaScript function, and
+ // {Parameter} indices start at -1, so value outputs of {Start} look like
+ // this: closure, receiver, param0, ..., paramN, context.
+ if (index == start->op()->ValueOutputCount() - 2) {
+ return context;
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ return MaybeHandle<Context>();
+}
+
+
+// static
+MaybeHandle<Context> NodeProperties::GetSpecializationNativeContext(
+ Node* node, MaybeHandle<Context> native_context) {
+ while (true) {
+ switch (node->opcode()) {
+ case IrOpcode::kJSCreateBlockContext:
+ case IrOpcode::kJSCreateCatchContext:
+ case IrOpcode::kJSCreateFunctionContext:
+ case IrOpcode::kJSCreateModuleContext:
+ case IrOpcode::kJSCreateScriptContext:
+ case IrOpcode::kJSCreateWithContext: {
+ // Skip over the intermediate contexts, we're only interested in the
+ // very last context in the context chain anyway.
+ node = NodeProperties::GetContextInput(node);
+ break;
+ }
+ case IrOpcode::kHeapConstant: {
+ // Extract the native context from the actual {context}.
+ Handle<Context> context =
+ Handle<Context>::cast(OpParameter<Handle<HeapObject>>(node));
+ return handle(context->native_context());
+ }
+ case IrOpcode::kOsrValue: {
+ int const index = OpParameter<int>(node);
+ if (index == Linkage::kOsrContextSpillSlotIndex) {
+ return native_context;
+ }
+ return MaybeHandle<Context>();
+ }
+ case IrOpcode::kParameter: {
+ Node* const start = NodeProperties::GetValueInput(node, 0);
+ DCHECK_EQ(IrOpcode::kStart, start->opcode());
+ int const index = ParameterIndexOf(node->op());
+ // The context is always the last parameter to a JavaScript function,
+ // and {Parameter} indices start at -1, so value outputs of {Start}
+ // look like this: closure, receiver, param0, ..., paramN, context.
+ if (index == start->op()->ValueOutputCount() - 2) {
+ return native_context;
+ }
+ return MaybeHandle<Context>();
+ }
+ default:
+ return MaybeHandle<Context>();
+ }
+ }
+}
+
+
+// static
+MaybeHandle<JSGlobalObject> NodeProperties::GetSpecializationGlobalObject(
+ Node* node, MaybeHandle<Context> native_context) {
+ Handle<Context> context;
+ if (GetSpecializationNativeContext(node, native_context).ToHandle(&context)) {
+ return handle(context->global_object());
+ }
+ return MaybeHandle<JSGlobalObject>();
+}
+
+
+// static
Type* NodeProperties::GetTypeOrAny(Node* node) {
return IsTyped(node) ? node->type() : Type::Any();
}