1b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch// Copyright 2014 the V8 project authors. All rights reserved. 2b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch// Use of this source code is governed by a BSD-style license that can be 3b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch// found in the LICENSE file. 4b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 5958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier#include "src/code-stubs.h" 6b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch#include "src/compiler/js-graph.h" 7014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch#include "src/compiler/node-properties.h" 8b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch#include "src/compiler/typer.h" 9b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 10b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochnamespace v8 { 11b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochnamespace internal { 12b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochnamespace compiler { 13b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 14014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch#define CACHED(name, expr) \ 15014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch cached_nodes_[name] ? cached_nodes_[name] : (cached_nodes_[name] = (expr)) 16b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 17537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben MurdochNode* JSGraph::AllocateInNewSpaceStubConstant() { 18537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch return CACHED(kAllocateInNewSpaceStubConstant, 19537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch HeapConstant(isolate()->builtins()->AllocateInNewSpace())); 20537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch} 21537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch 22537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben MurdochNode* JSGraph::AllocateInOldSpaceStubConstant() { 23537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch return CACHED(kAllocateInOldSpaceStubConstant, 24537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch HeapConstant(isolate()->builtins()->AllocateInOldSpace())); 25537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch} 26b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 2721efce637eb329c94f1323b6a2334a1c977e1a9dBen MurdochNode* JSGraph::ToNumberBuiltinConstant() { 2821efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch return CACHED(kToNumberBuiltinConstant, 2921efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch HeapConstant(isolate()->builtins()->ToNumber())); 3021efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch} 3121efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch 32958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily BernierNode* JSGraph::CEntryStubConstant(int result_size) { 33958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier if (result_size == 1) { 34014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return CACHED(kCEntryStubConstant, 35014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch HeapConstant(CEntryStub(isolate(), 1).GetCode())); 36b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 37014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return HeapConstant(CEntryStub(isolate(), result_size).GetCode()); 38014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} 39014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 40958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 41014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben MurdochNode* JSGraph::EmptyFixedArrayConstant() { 42014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return CACHED(kEmptyFixedArrayConstant, 43014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch HeapConstant(factory()->empty_fixed_array())); 44b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 45b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 4621efce637eb329c94f1323b6a2334a1c977e1a9dBen MurdochNode* JSGraph::EmptyLiteralsArrayConstant() { 4721efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch return CACHED(kEmptyLiteralsArrayConstant, 4821efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch HeapConstant(factory()->empty_literals_array())); 4921efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch} 5021efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch 51537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben MurdochNode* JSGraph::HeapNumberMapConstant() { 52537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch return CACHED(kHeapNumberMapConstant, 53537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch HeapConstant(factory()->heap_number_map())); 54537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch} 55537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch 561b268ca467c924004286c97bac133db489cf43d0Ben MurdochNode* JSGraph::OptimizedOutConstant() { 571b268ca467c924004286c97bac133db489cf43d0Ben Murdoch return CACHED(kOptimizedOutConstant, 581b268ca467c924004286c97bac133db489cf43d0Ben Murdoch HeapConstant(factory()->optimized_out())); 591b268ca467c924004286c97bac133db489cf43d0Ben Murdoch} 60b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 61537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben MurdochNode* JSGraph::StaleRegisterConstant() { 62537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch return CACHED(kStaleRegisterConstant, 63537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch HeapConstant(factory()->stale_register())); 64537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch} 65537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch 66b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochNode* JSGraph::UndefinedConstant() { 67014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return CACHED(kUndefinedConstant, HeapConstant(factory()->undefined_value())); 68b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 69b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 70b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 71b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochNode* JSGraph::TheHoleConstant() { 72014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return CACHED(kTheHoleConstant, HeapConstant(factory()->the_hole_value())); 73b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 74b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 75b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 76b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochNode* JSGraph::TrueConstant() { 77014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return CACHED(kTrueConstant, HeapConstant(factory()->true_value())); 78b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 79b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 80b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 81b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochNode* JSGraph::FalseConstant() { 82014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return CACHED(kFalseConstant, HeapConstant(factory()->false_value())); 83b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 84b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 85b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 86b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochNode* JSGraph::NullConstant() { 87014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return CACHED(kNullConstant, HeapConstant(factory()->null_value())); 88b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 89b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 90b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 91b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochNode* JSGraph::ZeroConstant() { 92014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return CACHED(kZeroConstant, NumberConstant(0.0)); 93b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 94b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 95b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 96b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochNode* JSGraph::OneConstant() { 97014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return CACHED(kOneConstant, NumberConstant(1.0)); 98b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 99b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 100b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 101b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochNode* JSGraph::NaNConstant() { 102014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return CACHED(kNaNConstant, 103014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch NumberConstant(std::numeric_limits<double>::quiet_NaN())); 104b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 105b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 106b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 107958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily BernierNode* JSGraph::HeapConstant(Handle<HeapObject> value) { 108014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Node** loc = cache_.FindHeapConstant(value); 109014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch if (*loc == nullptr) { 110014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch *loc = graph()->NewNode(common()->HeapConstant(value)); 111014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch } 112014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return *loc; 113b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 114b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 115b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 116b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochNode* JSGraph::Constant(Handle<Object> value) { 117b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // Dereference the handle to determine if a number constant or other 118b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // canonicalized node can be used. 119b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (value->IsNumber()) { 120b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return Constant(value->Number()); 12121efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch } else if (value->IsUndefined(isolate())) { 122b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return UndefinedConstant(); 12321efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch } else if (value->IsTrue(isolate())) { 124b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return TrueConstant(); 12521efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch } else if (value->IsFalse(isolate())) { 126b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return FalseConstant(); 12721efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch } else if (value->IsNull(isolate())) { 128b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return NullConstant(); 12921efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch } else if (value->IsTheHole(isolate())) { 130b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return TheHoleConstant(); 131b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } else { 132958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier return HeapConstant(Handle<HeapObject>::cast(value)); 133b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 134b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 135b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 136b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 137b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochNode* JSGraph::Constant(double value) { 138b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (bit_cast<int64_t>(value) == bit_cast<int64_t>(0.0)) return ZeroConstant(); 139b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (bit_cast<int64_t>(value) == bit_cast<int64_t>(1.0)) return OneConstant(); 140b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return NumberConstant(value); 141b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 142b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 143b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 144b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochNode* JSGraph::Constant(int32_t value) { 145b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (value == 0) return ZeroConstant(); 146b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (value == 1) return OneConstant(); 147b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return NumberConstant(value); 148b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 149b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 150b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 151b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochNode* JSGraph::Int32Constant(int32_t value) { 152b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch Node** loc = cache_.FindInt32Constant(value); 153014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch if (*loc == nullptr) { 154958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier *loc = graph()->NewNode(common()->Int32Constant(value)); 155958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier } 156958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier return *loc; 157958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier} 158958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 159958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 160958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily BernierNode* JSGraph::Int64Constant(int64_t value) { 161958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier Node** loc = cache_.FindInt64Constant(value); 162014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch if (*loc == nullptr) { 163958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier *loc = graph()->NewNode(common()->Int64Constant(value)); 164b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 165b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return *loc; 166b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 167b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 168537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben MurdochNode* JSGraph::RelocatableInt32Constant(int32_t value, RelocInfo::Mode rmode) { 16921efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch Node** loc = cache_.FindRelocatableInt32Constant( 17021efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch value, static_cast<RelocInfoMode>(rmode)); 171537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch if (*loc == nullptr) { 172537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch *loc = graph()->NewNode(common()->RelocatableInt32Constant(value, rmode)); 173537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch } 174537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch return *loc; 175537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch} 176537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch 177537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben MurdochNode* JSGraph::RelocatableInt64Constant(int64_t value, RelocInfo::Mode rmode) { 17821efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch Node** loc = cache_.FindRelocatableInt64Constant( 17921efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch value, static_cast<RelocInfoMode>(rmode)); 180537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch if (*loc == nullptr) { 181537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch *loc = graph()->NewNode(common()->RelocatableInt64Constant(value, rmode)); 182537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch } 183537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch return *loc; 184537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch} 185537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch 186537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben MurdochNode* JSGraph::RelocatableIntPtrConstant(intptr_t value, 187537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch RelocInfo::Mode rmode) { 188537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch return kPointerSize == 8 189537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch ? RelocatableInt64Constant(value, rmode) 190537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch : RelocatableInt32Constant(static_cast<int>(value), rmode); 191537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch} 192b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 193b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochNode* JSGraph::NumberConstant(double value) { 194b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch Node** loc = cache_.FindNumberConstant(value); 195014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch if (*loc == nullptr) { 196958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier *loc = graph()->NewNode(common()->NumberConstant(value)); 197958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier } 198958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier return *loc; 199958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier} 200958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 201958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 202958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily BernierNode* JSGraph::Float32Constant(float value) { 203958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier Node** loc = cache_.FindFloat32Constant(value); 204014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch if (*loc == nullptr) { 205958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier *loc = graph()->NewNode(common()->Float32Constant(value)); 206b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 207b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return *loc; 208b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 209b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 210b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 211b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochNode* JSGraph::Float64Constant(double value) { 212b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch Node** loc = cache_.FindFloat64Constant(value); 213014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch if (*loc == nullptr) { 214958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier *loc = graph()->NewNode(common()->Float64Constant(value)); 215b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 216b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return *loc; 217b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 218b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 219b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 220b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochNode* JSGraph::ExternalConstant(ExternalReference reference) { 221b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch Node** loc = cache_.FindExternalConstant(reference); 222014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch if (*loc == nullptr) { 223958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier *loc = graph()->NewNode(common()->ExternalConstant(reference)); 224b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch } 225b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return *loc; 226b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} 227958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 228958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 229014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben MurdochNode* JSGraph::ExternalConstant(Runtime::FunctionId function_id) { 230014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return ExternalConstant(ExternalReference(function_id, isolate())); 231014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} 232014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 23321efce637eb329c94f1323b6a2334a1c977e1a9dBen MurdochNode* JSGraph::EmptyStateValues() { 23421efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch return CACHED(kEmptyStateValues, graph()->NewNode(common()->StateValues(0))); 235014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} 236014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 237014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben MurdochNode* JSGraph::Dead() { 238014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return CACHED(kDead, graph()->NewNode(common()->Dead())); 239014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} 240014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 241014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 242958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Berniervoid JSGraph::GetCachedNodes(NodeVector* nodes) { 243958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier cache_.GetCachedNodes(nodes); 244014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch for (size_t i = 0; i < arraysize(cached_nodes_); i++) { 245014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch if (Node* node = cached_nodes_[i]) { 246014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch if (!node->IsDead()) nodes->push_back(node); 247014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch } 248958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier } 249958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier} 250958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 251b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} // namespace compiler 252b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} // namespace internal 253b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} // namespace v8 254