js-intrinsic-lowering.cc revision 537ba893e2530051ec7f296e769fdd37bb4ae4a0
1014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch// Copyright 2015 the V8 project authors. All rights reserved. 2014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch// Use of this source code is governed by a BSD-style license that can be 3014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch// found in the LICENSE file. 4014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 5014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch#include "src/compiler/js-intrinsic-lowering.h" 6014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 7014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch#include <stack> 8014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 9014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch#include "src/code-factory.h" 10014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch#include "src/compiler/access-builder.h" 11014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch#include "src/compiler/js-graph.h" 12014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch#include "src/compiler/linkage.h" 13014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch#include "src/compiler/node-matchers.h" 14014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch#include "src/compiler/node-properties.h" 15014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch#include "src/compiler/operator-properties.h" 16014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch#include "src/counters.h" 17014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch#include "src/objects-inl.h" 18014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 19014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdochnamespace v8 { 20014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdochnamespace internal { 21014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdochnamespace compiler { 22014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 23014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben MurdochJSIntrinsicLowering::JSIntrinsicLowering(Editor* editor, JSGraph* jsgraph, 24014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch DeoptimizationMode mode) 251b268ca467c924004286c97bac133db489cf43d0Ben Murdoch : AdvancedReducer(editor), jsgraph_(jsgraph), mode_(mode) {} 26014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 27014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben MurdochReduction JSIntrinsicLowering::Reduce(Node* node) { 28014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch if (node->opcode() != IrOpcode::kJSCallRuntime) return NoChange(); 29014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch const Runtime::Function* const f = 30014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Runtime::FunctionForId(CallRuntimeParametersOf(node->op()).id()); 31014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch if (f->intrinsic_type != Runtime::IntrinsicType::INLINE) return NoChange(); 32014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch switch (f->function_id) { 33014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch case Runtime::kInlineConstructDouble: 34014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return ReduceConstructDouble(node); 35014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch case Runtime::kInlineCreateIterResultObject: 36014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return ReduceCreateIterResultObject(node); 37014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch case Runtime::kInlineDeoptimizeNow: 38014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return ReduceDeoptimizeNow(node); 39014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch case Runtime::kInlineDoubleHi: 40014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return ReduceDoubleHi(node); 41014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch case Runtime::kInlineDoubleLo: 42014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return ReduceDoubleLo(node); 43014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch case Runtime::kInlineIsArray: 44014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return ReduceIsInstanceType(node, JS_ARRAY_TYPE); 45014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch case Runtime::kInlineIsTypedArray: 46014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return ReduceIsInstanceType(node, JS_TYPED_ARRAY_TYPE); 47014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch case Runtime::kInlineIsRegExp: 48014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return ReduceIsInstanceType(node, JS_REGEXP_TYPE); 49014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch case Runtime::kInlineIsJSReceiver: 50014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return ReduceIsJSReceiver(node); 51014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch case Runtime::kInlineIsSmi: 52014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return ReduceIsSmi(node); 53014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch case Runtime::kInlineValueOf: 54014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return ReduceValueOf(node); 55014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch case Runtime::kInlineFixedArrayGet: 56014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return ReduceFixedArrayGet(node); 57014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch case Runtime::kInlineFixedArraySet: 58014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return ReduceFixedArraySet(node); 59014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch case Runtime::kInlineRegExpConstructResult: 60014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return ReduceRegExpConstructResult(node); 61014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch case Runtime::kInlineRegExpExec: 62014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return ReduceRegExpExec(node); 63014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch case Runtime::kInlineRegExpFlags: 64014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return ReduceRegExpFlags(node); 65014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch case Runtime::kInlineRegExpSource: 66014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return ReduceRegExpSource(node); 67014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch case Runtime::kInlineSubString: 68014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return ReduceSubString(node); 69014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch case Runtime::kInlineToInteger: 70014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return ReduceToInteger(node); 71014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch case Runtime::kInlineToLength: 72014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return ReduceToLength(node); 73014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch case Runtime::kInlineToName: 74014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return ReduceToName(node); 75014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch case Runtime::kInlineToNumber: 76014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return ReduceToNumber(node); 77014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch case Runtime::kInlineToObject: 78014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return ReduceToObject(node); 79014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch case Runtime::kInlineToPrimitive: 80014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return ReduceToPrimitive(node); 81014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch case Runtime::kInlineToString: 82014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return ReduceToString(node); 83014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch case Runtime::kInlineCall: 84014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return ReduceCall(node); 851b268ca467c924004286c97bac133db489cf43d0Ben Murdoch case Runtime::kInlineNewObject: 861b268ca467c924004286c97bac133db489cf43d0Ben Murdoch return ReduceNewObject(node); 87014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch case Runtime::kInlineGetSuperConstructor: 88014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return ReduceGetSuperConstructor(node); 89014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch default: 90014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch break; 91014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch } 92014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return NoChange(); 93014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} 94014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 95014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 96014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben MurdochReduction JSIntrinsicLowering::ReduceCreateIterResultObject(Node* node) { 97014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* const value = NodeProperties::GetValueInput(node, 0); 98014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* const done = NodeProperties::GetValueInput(node, 1); 99014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* const context = NodeProperties::GetContextInput(node); 100014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* const effect = NodeProperties::GetEffectInput(node); 101014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return Change(node, javascript()->CreateIterResultObject(), value, done, 102014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch context, effect); 103014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} 104014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 105014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 106014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben MurdochReduction JSIntrinsicLowering::ReduceConstructDouble(Node* node) { 107014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* high = NodeProperties::GetValueInput(node, 0); 108014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* low = NodeProperties::GetValueInput(node, 1); 109014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* value = 110014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch graph()->NewNode(machine()->Float64InsertHighWord32(), 111014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch graph()->NewNode(machine()->Float64InsertLowWord32(), 112014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch jsgraph()->Constant(0), low), 113014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch high); 114014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch ReplaceWithValue(node, value); 115014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return Replace(value); 116014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} 117014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 118014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 119014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben MurdochReduction JSIntrinsicLowering::ReduceDeoptimizeNow(Node* node) { 120014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch if (mode() != kDeoptimizationEnabled) return NoChange(); 121014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* const frame_state = NodeProperties::GetFrameStateInput(node, 0); 122014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* const effect = NodeProperties::GetEffectInput(node); 123014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* const control = NodeProperties::GetControlInput(node); 124014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 125014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch // TODO(bmeurer): Move MergeControlToEnd() to the AdvancedReducer. 126014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* deoptimize = 127014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch graph()->NewNode(common()->Deoptimize(DeoptimizeKind::kEager), 128014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch frame_state, effect, control); 129014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch NodeProperties::MergeControlToEnd(graph(), common(), deoptimize); 130342c50ce1624b485728b9a4fc41d8bbf37eb46cfBen Murdoch Revisit(graph()->end()); 131014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 132014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch node->TrimInputCount(0); 133014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch NodeProperties::ChangeOp(node, common()->Dead()); 134014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return Changed(node); 135014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} 136014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 137014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 138014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben MurdochReduction JSIntrinsicLowering::ReduceDoubleHi(Node* node) { 1391b268ca467c924004286c97bac133db489cf43d0Ben Murdoch // Tell the compiler to assume number input. 140537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch Node* renamed = graph()->NewNode(simplified()->TypeGuard(Type::Number()), 1411b268ca467c924004286c97bac133db489cf43d0Ben Murdoch node->InputAt(0), graph()->start()); 1421b268ca467c924004286c97bac133db489cf43d0Ben Murdoch node->ReplaceInput(0, renamed); 143014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return Change(node, machine()->Float64ExtractHighWord32()); 144014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} 145014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 146014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 147014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben MurdochReduction JSIntrinsicLowering::ReduceDoubleLo(Node* node) { 1481b268ca467c924004286c97bac133db489cf43d0Ben Murdoch // Tell the compiler to assume number input. 149537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch Node* renamed = graph()->NewNode(simplified()->TypeGuard(Type::Number()), 1501b268ca467c924004286c97bac133db489cf43d0Ben Murdoch node->InputAt(0), graph()->start()); 1511b268ca467c924004286c97bac133db489cf43d0Ben Murdoch node->ReplaceInput(0, renamed); 152014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return Change(node, machine()->Float64ExtractLowWord32()); 153014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} 154014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 155014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 156014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben MurdochReduction JSIntrinsicLowering::ReduceIsInstanceType( 157014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* node, InstanceType instance_type) { 158014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch // if (%_IsSmi(value)) { 159014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch // return false; 160014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch // } else { 161014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch // return %_GetInstanceType(%_GetMap(value)) == instance_type; 162014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch // } 163014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* value = NodeProperties::GetValueInput(node, 0); 164014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* effect = NodeProperties::GetEffectInput(node); 165014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* control = NodeProperties::GetControlInput(node); 166014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 167014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), value); 168014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* branch = graph()->NewNode(common()->Branch(), check, control); 169014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 170014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* if_true = graph()->NewNode(common()->IfTrue(), branch); 171014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* etrue = effect; 172014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* vtrue = jsgraph()->FalseConstant(); 173014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 174014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* if_false = graph()->NewNode(common()->IfFalse(), branch); 175014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* efalse = graph()->NewNode( 176014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch simplified()->LoadField(AccessBuilder::ForMapInstanceType()), 177014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch graph()->NewNode(simplified()->LoadField(AccessBuilder::ForMap()), value, 178014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch effect, if_false), 179014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch effect, if_false); 180014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* vfalse = graph()->NewNode(machine()->Word32Equal(), efalse, 181014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch jsgraph()->Int32Constant(instance_type)); 182014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 183014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false); 184014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 185014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch // Replace all effect uses of {node} with the {ephi}. 186014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* ephi = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, merge); 187014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch ReplaceWithValue(node, node, ephi); 188014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 189014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch // Turn the {node} into a Phi. 190014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return Change(node, common()->Phi(MachineRepresentation::kTagged, 2), vtrue, 191014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch vfalse, merge); 192014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} 193014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 194014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 195014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben MurdochReduction JSIntrinsicLowering::ReduceIsJSReceiver(Node* node) { 196342c50ce1624b485728b9a4fc41d8bbf37eb46cfBen Murdoch return Change(node, simplified()->ObjectIsReceiver()); 197014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} 198014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 199014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 200014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben MurdochReduction JSIntrinsicLowering::ReduceIsSmi(Node* node) { 201014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return Change(node, simplified()->ObjectIsSmi()); 202014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} 203014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 204014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 205014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben MurdochReduction JSIntrinsicLowering::ReduceValueOf(Node* node) { 206014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch // if (%_IsSmi(value)) { 207014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch // return value; 208014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch // } else if (%_GetInstanceType(%_GetMap(value)) == JS_VALUE_TYPE) { 209014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch // return %_GetValue(value); 210014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch // } else { 211014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch // return value; 212014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch // } 213014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch const Operator* const merge_op = common()->Merge(2); 214014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch const Operator* const ephi_op = common()->EffectPhi(2); 215014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch const Operator* const phi_op = 216014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch common()->Phi(MachineRepresentation::kTagged, 2); 217014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 218014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* value = NodeProperties::GetValueInput(node, 0); 219014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* effect = NodeProperties::GetEffectInput(node); 220014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* control = NodeProperties::GetControlInput(node); 221014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 222014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* check0 = graph()->NewNode(simplified()->ObjectIsSmi(), value); 223014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* branch0 = graph()->NewNode(common()->Branch(), check0, control); 224014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 225014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* if_true0 = graph()->NewNode(common()->IfTrue(), branch0); 226014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* etrue0 = effect; 227014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* vtrue0 = value; 228014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 229014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* if_false0 = graph()->NewNode(common()->IfFalse(), branch0); 230014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* efalse0; 231014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* vfalse0; 232014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch { 233014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* check1 = graph()->NewNode( 234014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch machine()->Word32Equal(), 235014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch graph()->NewNode( 236014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch simplified()->LoadField(AccessBuilder::ForMapInstanceType()), 237014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch graph()->NewNode(simplified()->LoadField(AccessBuilder::ForMap()), 238014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch value, effect, if_false0), 239014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch effect, if_false0), 240014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch jsgraph()->Int32Constant(JS_VALUE_TYPE)); 241014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* branch1 = graph()->NewNode(common()->Branch(), check1, if_false0); 242014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 243014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* if_true1 = graph()->NewNode(common()->IfTrue(), branch1); 244014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* etrue1 = 245014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch graph()->NewNode(simplified()->LoadField(AccessBuilder::ForValue()), 246014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch value, effect, if_true1); 247014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* vtrue1 = etrue1; 248014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 249014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* if_false1 = graph()->NewNode(common()->IfFalse(), branch1); 250014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* efalse1 = effect; 251014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* vfalse1 = value; 252014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 253014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* merge1 = graph()->NewNode(merge_op, if_true1, if_false1); 254014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch efalse0 = graph()->NewNode(ephi_op, etrue1, efalse1, merge1); 255014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch vfalse0 = graph()->NewNode(phi_op, vtrue1, vfalse1, merge1); 256014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch } 257014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 258014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* merge0 = graph()->NewNode(merge_op, if_true0, if_false0); 259014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 260014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch // Replace all effect uses of {node} with the {ephi0}. 261014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* ephi0 = graph()->NewNode(ephi_op, etrue0, efalse0, merge0); 262014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch ReplaceWithValue(node, node, ephi0); 263014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 264014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch // Turn the {node} into a Phi. 265014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return Change(node, phi_op, vtrue0, vfalse0, merge0); 266014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} 267014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 268014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 269014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben MurdochReduction JSIntrinsicLowering::Change(Node* node, const Operator* op) { 270014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch // Replace all effect uses of {node} with the effect dependency. 271014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch RelaxEffectsAndControls(node); 272014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch // Remove the inputs corresponding to context, effect and control. 273014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch NodeProperties::RemoveNonValueInputs(node); 274014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch // Finally update the operator to the new one. 275014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch NodeProperties::ChangeOp(node, op); 276014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return Changed(node); 277014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} 278014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 279014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 280014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben MurdochReduction JSIntrinsicLowering::ReduceFixedArrayGet(Node* node) { 281014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* base = node->InputAt(0); 282014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* index = node->InputAt(1); 283014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* effect = NodeProperties::GetEffectInput(node); 284014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* control = NodeProperties::GetControlInput(node); 285014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return Change( 286014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch node, simplified()->LoadElement(AccessBuilder::ForFixedArrayElement()), 287014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch base, index, effect, control); 288014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} 289014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 290014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 291014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben MurdochReduction JSIntrinsicLowering::ReduceFixedArraySet(Node* node) { 292014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* base = node->InputAt(0); 293014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* index = node->InputAt(1); 294014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* value = node->InputAt(2); 295014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* effect = NodeProperties::GetEffectInput(node); 296014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* control = NodeProperties::GetControlInput(node); 297014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* store = (graph()->NewNode( 298014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch simplified()->StoreElement(AccessBuilder::ForFixedArrayElement()), base, 299014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch index, value, effect, control)); 300014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch ReplaceWithValue(node, value, store); 301014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return Changed(store); 302014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} 303014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 304014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 305014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben MurdochReduction JSIntrinsicLowering::ReduceRegExpConstructResult(Node* node) { 306014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch // TODO(bmeurer): Introduce JSCreateRegExpResult? 307014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return Change(node, CodeFactory::RegExpConstructResult(isolate()), 0); 308014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} 309014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 310014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 311014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben MurdochReduction JSIntrinsicLowering::ReduceRegExpExec(Node* node) { 312014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return Change(node, CodeFactory::RegExpExec(isolate()), 4); 313014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} 314014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 315014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 316014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben MurdochReduction JSIntrinsicLowering::ReduceRegExpFlags(Node* node) { 317014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* const receiver = NodeProperties::GetValueInput(node, 0); 318014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* const effect = NodeProperties::GetEffectInput(node); 319014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* const control = NodeProperties::GetControlInput(node); 320014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Operator const* const op = 321014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch simplified()->LoadField(AccessBuilder::ForJSRegExpFlags()); 322014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return Change(node, op, receiver, effect, control); 323014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} 324014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 325014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 326014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben MurdochReduction JSIntrinsicLowering::ReduceRegExpSource(Node* node) { 327014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* const receiver = NodeProperties::GetValueInput(node, 0); 328014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* const effect = NodeProperties::GetEffectInput(node); 329014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* const control = NodeProperties::GetControlInput(node); 330014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Operator const* const op = 331014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch simplified()->LoadField(AccessBuilder::ForJSRegExpSource()); 332014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return Change(node, op, receiver, effect, control); 333014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} 334014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 335014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 336014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben MurdochReduction JSIntrinsicLowering::ReduceSubString(Node* node) { 337014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return Change(node, CodeFactory::SubString(isolate()), 3); 338014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} 339014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 340014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 341014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben MurdochReduction JSIntrinsicLowering::ReduceToInteger(Node* node) { 3421b268ca467c924004286c97bac133db489cf43d0Ben Murdoch NodeProperties::ChangeOp(node, javascript()->ToInteger()); 3431b268ca467c924004286c97bac133db489cf43d0Ben Murdoch return Changed(node); 344014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} 345014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 346014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 347014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben MurdochReduction JSIntrinsicLowering::ReduceToName(Node* node) { 348014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch NodeProperties::ChangeOp(node, javascript()->ToName()); 349014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return Changed(node); 350014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} 351014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 352014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 353014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben MurdochReduction JSIntrinsicLowering::ReduceToNumber(Node* node) { 354014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch NodeProperties::ChangeOp(node, javascript()->ToNumber()); 355014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return Changed(node); 356014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} 357014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 358014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 359014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben MurdochReduction JSIntrinsicLowering::ReduceToLength(Node* node) { 3601b268ca467c924004286c97bac133db489cf43d0Ben Murdoch NodeProperties::ChangeOp(node, javascript()->ToLength()); 3611b268ca467c924004286c97bac133db489cf43d0Ben Murdoch return Changed(node); 362014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} 363014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 364014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 365014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben MurdochReduction JSIntrinsicLowering::ReduceToObject(Node* node) { 366014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch NodeProperties::ChangeOp(node, javascript()->ToObject()); 367014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return Changed(node); 368014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} 369014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 370014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 371014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben MurdochReduction JSIntrinsicLowering::ReduceToPrimitive(Node* node) { 372014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* value = NodeProperties::GetValueInput(node, 0); 373014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Type* value_type = NodeProperties::GetType(value); 374014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch if (value_type->Is(Type::Primitive())) { 375014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch ReplaceWithValue(node, value); 376014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return Replace(value); 377014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch } 378014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return NoChange(); 379014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} 380014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 381014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 382014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben MurdochReduction JSIntrinsicLowering::ReduceToString(Node* node) { 383014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch NodeProperties::ChangeOp(node, javascript()->ToString()); 384014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return Changed(node); 385014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} 386014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 387014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 388014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben MurdochReduction JSIntrinsicLowering::ReduceCall(Node* node) { 389014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch size_t const arity = CallRuntimeParametersOf(node->op()).arity(); 390342c50ce1624b485728b9a4fc41d8bbf37eb46cfBen Murdoch NodeProperties::ChangeOp(node, 391342c50ce1624b485728b9a4fc41d8bbf37eb46cfBen Murdoch javascript()->CallFunction(arity, VectorSlotPair(), 392342c50ce1624b485728b9a4fc41d8bbf37eb46cfBen Murdoch ConvertReceiverMode::kAny, 393342c50ce1624b485728b9a4fc41d8bbf37eb46cfBen Murdoch TailCallMode::kDisallow)); 394014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return Changed(node); 395014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} 396014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 3971b268ca467c924004286c97bac133db489cf43d0Ben MurdochReduction JSIntrinsicLowering::ReduceNewObject(Node* node) { 398537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch return Change(node, CodeFactory::FastNewObject(isolate()), 0); 399014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} 400014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 401014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben MurdochReduction JSIntrinsicLowering::ReduceGetSuperConstructor(Node* node) { 402014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* active_function = NodeProperties::GetValueInput(node, 0); 403014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* effect = NodeProperties::GetEffectInput(node); 404014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* control = NodeProperties::GetControlInput(node); 405014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* active_function_map = effect = 406014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch graph()->NewNode(simplified()->LoadField(AccessBuilder::ForMap()), 407014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch active_function, effect, control); 408014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return Change(node, simplified()->LoadField(AccessBuilder::ForMapPrototype()), 409014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch active_function_map, effect, control); 410014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} 411014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 412014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben MurdochReduction JSIntrinsicLowering::Change(Node* node, const Operator* op, Node* a, 413014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* b) { 414014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch RelaxControls(node); 415014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch node->ReplaceInput(0, a); 416014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch node->ReplaceInput(1, b); 417014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch node->TrimInputCount(2); 418014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch NodeProperties::ChangeOp(node, op); 419014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return Changed(node); 420014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} 421014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 422014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 423014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben MurdochReduction JSIntrinsicLowering::Change(Node* node, const Operator* op, Node* a, 424014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* b, Node* c) { 425014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch RelaxControls(node); 426014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch node->ReplaceInput(0, a); 427014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch node->ReplaceInput(1, b); 428014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch node->ReplaceInput(2, c); 429014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch node->TrimInputCount(3); 430014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch NodeProperties::ChangeOp(node, op); 431014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return Changed(node); 432014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} 433014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 434014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 435014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben MurdochReduction JSIntrinsicLowering::Change(Node* node, const Operator* op, Node* a, 436014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node* b, Node* c, Node* d) { 437014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch RelaxControls(node); 438014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch node->ReplaceInput(0, a); 439014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch node->ReplaceInput(1, b); 440014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch node->ReplaceInput(2, c); 441014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch node->ReplaceInput(3, d); 442014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch node->TrimInputCount(4); 443014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch NodeProperties::ChangeOp(node, op); 444014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return Changed(node); 445014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} 446014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 447014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 448014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben MurdochReduction JSIntrinsicLowering::Change(Node* node, Callable const& callable, 449014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch int stack_parameter_count) { 450014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch CallDescriptor const* const desc = Linkage::GetStubCallDescriptor( 451014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch isolate(), graph()->zone(), callable.descriptor(), stack_parameter_count, 452014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch CallDescriptor::kNeedsFrameState, node->op()->properties()); 453014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch node->InsertInput(graph()->zone(), 0, 454014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch jsgraph()->HeapConstant(callable.code())); 455014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch NodeProperties::ChangeOp(node, common()->Call(desc)); 456014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return Changed(node); 457014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} 458014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 459014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 460014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben MurdochGraph* JSIntrinsicLowering::graph() const { return jsgraph()->graph(); } 461014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 462014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 463014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben MurdochIsolate* JSIntrinsicLowering::isolate() const { return jsgraph()->isolate(); } 464014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 465014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 466014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben MurdochCommonOperatorBuilder* JSIntrinsicLowering::common() const { 467014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return jsgraph()->common(); 468014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} 469014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 470014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben MurdochJSOperatorBuilder* JSIntrinsicLowering::javascript() const { 471014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return jsgraph_->javascript(); 472014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} 473014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 474014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 475014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben MurdochMachineOperatorBuilder* JSIntrinsicLowering::machine() const { 476014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return jsgraph()->machine(); 477014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} 478014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 479014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 480014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben MurdochSimplifiedOperatorBuilder* JSIntrinsicLowering::simplified() const { 481014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return jsgraph()->simplified(); 482014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} 483014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 484014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} // namespace compiler 485014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} // namespace internal 486014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} // namespace v8 487