Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 1 | // Copyright 2012 the V8 project authors. All rights reserved. |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 4 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 5 | #include "src/code-stubs.h" |
| 6 | |
| 7 | #include <sstream> |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 8 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 9 | #include "src/bootstrapper.h" |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 10 | #include "src/compiler/code-stub-assembler.h" |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 11 | #include "src/factory.h" |
| 12 | #include "src/gdb-jit.h" |
| 13 | #include "src/ic/handler-compiler.h" |
| 14 | #include "src/ic/ic.h" |
| 15 | #include "src/macro-assembler.h" |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 16 | #include "src/parsing/parser.h" |
| 17 | #include "src/profiler/cpu-profiler.h" |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 18 | |
| 19 | namespace v8 { |
| 20 | namespace internal { |
| 21 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 22 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 23 | RUNTIME_FUNCTION(UnexpectedStubMiss) { |
| 24 | FATAL("Unexpected deopt of a stub"); |
| 25 | return Smi::FromInt(0); |
| 26 | } |
| 27 | |
| 28 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 29 | CodeStubDescriptor::CodeStubDescriptor(CodeStub* stub) |
| 30 | : call_descriptor_(stub->GetCallInterfaceDescriptor()), |
| 31 | stack_parameter_count_(no_reg), |
| 32 | hint_stack_parameter_count_(-1), |
| 33 | function_mode_(NOT_JS_FUNCTION_STUB_MODE), |
| 34 | deoptimization_handler_(NULL), |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 35 | miss_handler_(), |
| 36 | has_miss_handler_(false) { |
| 37 | stub->InitializeDescriptor(this); |
| 38 | } |
| 39 | |
| 40 | |
| 41 | CodeStubDescriptor::CodeStubDescriptor(Isolate* isolate, uint32_t stub_key) |
| 42 | : stack_parameter_count_(no_reg), |
| 43 | hint_stack_parameter_count_(-1), |
| 44 | function_mode_(NOT_JS_FUNCTION_STUB_MODE), |
| 45 | deoptimization_handler_(NULL), |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 46 | miss_handler_(), |
| 47 | has_miss_handler_(false) { |
| 48 | CodeStub::InitializeDescriptor(isolate, stub_key, this); |
| 49 | } |
| 50 | |
| 51 | |
| 52 | void CodeStubDescriptor::Initialize(Address deoptimization_handler, |
| 53 | int hint_stack_parameter_count, |
| 54 | StubFunctionMode function_mode) { |
| 55 | deoptimization_handler_ = deoptimization_handler; |
| 56 | hint_stack_parameter_count_ = hint_stack_parameter_count; |
| 57 | function_mode_ = function_mode; |
| 58 | } |
| 59 | |
| 60 | |
| 61 | void CodeStubDescriptor::Initialize(Register stack_parameter_count, |
| 62 | Address deoptimization_handler, |
| 63 | int hint_stack_parameter_count, |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 64 | StubFunctionMode function_mode) { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 65 | Initialize(deoptimization_handler, hint_stack_parameter_count, function_mode); |
| 66 | stack_parameter_count_ = stack_parameter_count; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | |
Leon Clarke | e46be81 | 2010-01-19 14:06:41 +0000 | [diff] [blame] | 70 | bool CodeStub::FindCodeInCache(Code** code_out) { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 71 | UnseededNumberDictionary* stubs = isolate()->heap()->code_stubs(); |
| 72 | int index = stubs->FindEntry(GetKey()); |
Ben Murdoch | c7cc028 | 2012-03-05 14:35:55 +0000 | [diff] [blame] | 73 | if (index != UnseededNumberDictionary::kNotFound) { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 74 | *code_out = Code::cast(stubs->ValueAt(index)); |
Leon Clarke | e46be81 | 2010-01-19 14:06:41 +0000 | [diff] [blame] | 75 | return true; |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 76 | } |
Leon Clarke | e46be81 | 2010-01-19 14:06:41 +0000 | [diff] [blame] | 77 | return false; |
| 78 | } |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 79 | |
Leon Clarke | e46be81 | 2010-01-19 14:06:41 +0000 | [diff] [blame] | 80 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 81 | void CodeStub::RecordCodeGeneration(Handle<Code> code) { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 82 | std::ostringstream os; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 83 | os << *this; |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 84 | PROFILE(isolate(), |
| 85 | CodeCreateEvent(Logger::STUB_TAG, *code, os.str().c_str())); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 86 | Counters* counters = isolate()->counters(); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 87 | counters->total_stubs_code_size()->Increment(code->instruction_size()); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 88 | #ifdef DEBUG |
| 89 | code->VerifyEmbeddedObjects(); |
| 90 | #endif |
Leon Clarke | e46be81 | 2010-01-19 14:06:41 +0000 | [diff] [blame] | 91 | } |
| 92 | |
| 93 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 94 | Code::Kind CodeStub::GetCodeKind() const { |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 95 | return Code::STUB; |
| 96 | } |
| 97 | |
| 98 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame^] | 99 | Code::Flags CodeStub::GetCodeFlags() const { |
| 100 | return Code::ComputeFlags(GetCodeKind(), GetICState(), GetExtraICState(), |
| 101 | GetStubType()); |
| 102 | } |
| 103 | |
| 104 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 105 | Handle<Code> CodeStub::GetCodeCopy(const Code::FindAndReplacePattern& pattern) { |
| 106 | Handle<Code> ic = GetCode(); |
| 107 | ic = isolate()->factory()->CopyCode(ic); |
| 108 | ic->FindAndReplace(pattern); |
| 109 | RecordCodeGeneration(ic); |
| 110 | return ic; |
| 111 | } |
| 112 | |
| 113 | |
| 114 | Handle<Code> PlatformCodeStub::GenerateCode() { |
| 115 | Factory* factory = isolate()->factory(); |
| 116 | |
| 117 | // Generate the new code. |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 118 | MacroAssembler masm(isolate(), NULL, 256, CodeObjectRequired::kYes); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 119 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 120 | { |
| 121 | // Update the static counter each time a new code stub is generated. |
| 122 | isolate()->counters()->code_stubs()->Increment(); |
| 123 | |
| 124 | // Generate the code for the stub. |
| 125 | masm.set_generating_stub(true); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 126 | // TODO(yangguo): remove this once we can serialize IC stubs. |
| 127 | masm.enable_serializer(); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 128 | NoCurrentFrameScope scope(&masm); |
| 129 | Generate(&masm); |
| 130 | } |
| 131 | |
| 132 | // Create the code object. |
| 133 | CodeDesc desc; |
| 134 | masm.GetCode(&desc); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 135 | // Copy the generated code into a heap object. |
| 136 | Code::Flags flags = Code::ComputeFlags( |
| 137 | GetCodeKind(), |
| 138 | GetICState(), |
| 139 | GetExtraICState(), |
| 140 | GetStubType()); |
| 141 | Handle<Code> new_object = factory->NewCode( |
| 142 | desc, flags, masm.CodeObject(), NeedsImmovableCode()); |
| 143 | return new_object; |
| 144 | } |
| 145 | |
| 146 | |
Leon Clarke | e46be81 | 2010-01-19 14:06:41 +0000 | [diff] [blame] | 147 | Handle<Code> CodeStub::GetCode() { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 148 | Heap* heap = isolate()->heap(); |
Leon Clarke | e46be81 | 2010-01-19 14:06:41 +0000 | [diff] [blame] | 149 | Code* code; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 150 | if (UseSpecialCache() ? FindCodeInSpecialCache(&code) |
| 151 | : FindCodeInCache(&code)) { |
| 152 | DCHECK(GetCodeKind() == code->kind()); |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 153 | return Handle<Code>(code); |
| 154 | } |
| 155 | |
| 156 | { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 157 | HandleScope scope(isolate()); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 158 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 159 | Handle<Code> new_object = GenerateCode(); |
| 160 | new_object->set_stub_key(GetKey()); |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 161 | FinishCode(new_object); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 162 | RecordCodeGeneration(new_object); |
| 163 | |
| 164 | #ifdef ENABLE_DISASSEMBLER |
| 165 | if (FLAG_print_code_stubs) { |
| 166 | CodeTracer::Scope trace_scope(isolate()->GetCodeTracer()); |
| 167 | OFStream os(trace_scope.file()); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 168 | std::ostringstream name; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 169 | name << *this; |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 170 | new_object->Disassemble(name.str().c_str(), os); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 171 | os << "\n"; |
| 172 | } |
| 173 | #endif |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 174 | |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 175 | if (UseSpecialCache()) { |
| 176 | AddToSpecialCache(new_object); |
| 177 | } else { |
| 178 | // Update the dictionary and the root in Heap. |
| 179 | Handle<UnseededNumberDictionary> dict = |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 180 | UnseededNumberDictionary::AtNumberPut( |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 181 | Handle<UnseededNumberDictionary>(heap->code_stubs()), |
| 182 | GetKey(), |
| 183 | new_object); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 184 | heap->SetRootCodeStubs(*dict); |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 185 | } |
Leon Clarke | e46be81 | 2010-01-19 14:06:41 +0000 | [diff] [blame] | 186 | code = *new_object; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 187 | } |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 188 | |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 189 | Activate(code); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 190 | DCHECK(!NeedsImmovableCode() || |
| 191 | heap->lo_space()->Contains(code) || |
| 192 | heap->code_space()->FirstPage()->Contains(code->address())); |
| 193 | return Handle<Code>(code, isolate()); |
Leon Clarke | e46be81 | 2010-01-19 14:06:41 +0000 | [diff] [blame] | 194 | } |
| 195 | |
| 196 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 197 | const char* CodeStub::MajorName(CodeStub::Major major_key) { |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 198 | switch (major_key) { |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 199 | #define DEF_CASE(name) case name: return #name "Stub"; |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 200 | CODE_STUB_LIST(DEF_CASE) |
| 201 | #undef DEF_CASE |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 202 | case NoCache: |
| 203 | return "<NoCache>Stub"; |
| 204 | case NUMBER_OF_IDS: |
| 205 | UNREACHABLE(); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 206 | return NULL; |
| 207 | } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 208 | return NULL; |
| 209 | } |
| 210 | |
| 211 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 212 | void CodeStub::PrintBaseName(std::ostream& os) const { // NOLINT |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 213 | os << MajorName(MajorKey()); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 214 | } |
| 215 | |
| 216 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 217 | void CodeStub::PrintName(std::ostream& os) const { // NOLINT |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 218 | PrintBaseName(os); |
| 219 | PrintState(os); |
| 220 | } |
| 221 | |
| 222 | |
| 223 | void CodeStub::Dispatch(Isolate* isolate, uint32_t key, void** value_out, |
| 224 | DispatchedCall call) { |
| 225 | switch (MajorKeyFromKey(key)) { |
| 226 | #define DEF_CASE(NAME) \ |
| 227 | case NAME: { \ |
| 228 | NAME##Stub stub(key, isolate); \ |
| 229 | CodeStub* pstub = &stub; \ |
| 230 | call(pstub, value_out); \ |
| 231 | break; \ |
| 232 | } |
| 233 | CODE_STUB_LIST(DEF_CASE) |
| 234 | #undef DEF_CASE |
| 235 | case NUMBER_OF_IDS: |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 236 | case NoCache: |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 237 | UNREACHABLE(); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 238 | break; |
| 239 | } |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 240 | } |
| 241 | |
| 242 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 243 | static void InitializeDescriptorDispatchedCall(CodeStub* stub, |
| 244 | void** value_out) { |
| 245 | CodeStubDescriptor* descriptor_out = |
| 246 | reinterpret_cast<CodeStubDescriptor*>(value_out); |
| 247 | stub->InitializeDescriptor(descriptor_out); |
| 248 | descriptor_out->set_call_descriptor(stub->GetCallInterfaceDescriptor()); |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 249 | } |
| 250 | |
| 251 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 252 | void CodeStub::InitializeDescriptor(Isolate* isolate, uint32_t key, |
| 253 | CodeStubDescriptor* desc) { |
| 254 | void** value_out = reinterpret_cast<void**>(desc); |
| 255 | Dispatch(isolate, key, value_out, &InitializeDescriptorDispatchedCall); |
| 256 | } |
| 257 | |
| 258 | |
| 259 | void CodeStub::GetCodeDispatchCall(CodeStub* stub, void** value_out) { |
| 260 | Handle<Code>* code_out = reinterpret_cast<Handle<Code>*>(value_out); |
| 261 | // Code stubs with special cache cannot be recreated from stub key. |
| 262 | *code_out = stub->UseSpecialCache() ? Handle<Code>() : stub->GetCode(); |
| 263 | } |
| 264 | |
| 265 | |
| 266 | MaybeHandle<Code> CodeStub::GetCode(Isolate* isolate, uint32_t key) { |
| 267 | HandleScope scope(isolate); |
| 268 | Handle<Code> code; |
| 269 | void** value_out = reinterpret_cast<void**>(&code); |
| 270 | Dispatch(isolate, key, value_out, &GetCodeDispatchCall); |
| 271 | return scope.CloseAndEscape(code); |
| 272 | } |
| 273 | |
| 274 | |
| 275 | // static |
| 276 | void BinaryOpICStub::GenerateAheadOfTime(Isolate* isolate) { |
| 277 | // Generate the uninitialized versions of the stub. |
| 278 | for (int op = Token::BIT_OR; op <= Token::MOD; ++op) { |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame^] | 279 | BinaryOpICStub stub(isolate, static_cast<Token::Value>(op)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 280 | stub.GetCode(); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 281 | } |
| 282 | |
| 283 | // Generate special versions of the stub. |
| 284 | BinaryOpICState::GenerateAheadOfTime(isolate, &GenerateAheadOfTime); |
| 285 | } |
| 286 | |
| 287 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 288 | void BinaryOpICStub::PrintState(std::ostream& os) const { // NOLINT |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 289 | os << state(); |
| 290 | } |
| 291 | |
| 292 | |
| 293 | // static |
| 294 | void BinaryOpICStub::GenerateAheadOfTime(Isolate* isolate, |
| 295 | const BinaryOpICState& state) { |
| 296 | BinaryOpICStub stub(isolate, state); |
| 297 | stub.GetCode(); |
| 298 | } |
| 299 | |
| 300 | |
| 301 | // static |
| 302 | void BinaryOpICWithAllocationSiteStub::GenerateAheadOfTime(Isolate* isolate) { |
| 303 | // Generate special versions of the stub. |
| 304 | BinaryOpICState::GenerateAheadOfTime(isolate, &GenerateAheadOfTime); |
| 305 | } |
| 306 | |
| 307 | |
| 308 | void BinaryOpICWithAllocationSiteStub::PrintState( |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 309 | std::ostream& os) const { // NOLINT |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 310 | os << state(); |
| 311 | } |
| 312 | |
| 313 | |
| 314 | // static |
| 315 | void BinaryOpICWithAllocationSiteStub::GenerateAheadOfTime( |
| 316 | Isolate* isolate, const BinaryOpICState& state) { |
| 317 | if (state.CouldCreateAllocationMementos()) { |
| 318 | BinaryOpICWithAllocationSiteStub stub(isolate, state); |
| 319 | stub.GetCode(); |
| 320 | } |
| 321 | } |
| 322 | |
| 323 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 324 | std::ostream& operator<<(std::ostream& os, const StringAddFlags& flags) { |
| 325 | switch (flags) { |
| 326 | case STRING_ADD_CHECK_NONE: |
| 327 | return os << "CheckNone"; |
| 328 | case STRING_ADD_CHECK_LEFT: |
| 329 | return os << "CheckLeft"; |
| 330 | case STRING_ADD_CHECK_RIGHT: |
| 331 | return os << "CheckRight"; |
| 332 | case STRING_ADD_CHECK_BOTH: |
| 333 | return os << "CheckBoth"; |
| 334 | case STRING_ADD_CONVERT_LEFT: |
| 335 | return os << "ConvertLeft"; |
| 336 | case STRING_ADD_CONVERT_RIGHT: |
| 337 | return os << "ConvertRight"; |
| 338 | case STRING_ADD_CONVERT: |
| 339 | break; |
| 340 | } |
| 341 | UNREACHABLE(); |
| 342 | return os; |
| 343 | } |
| 344 | |
| 345 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 346 | void StringAddStub::PrintBaseName(std::ostream& os) const { // NOLINT |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 347 | os << "StringAddStub_" << flags() << "_" << pretenure_flag(); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 348 | } |
| 349 | |
| 350 | |
| 351 | InlineCacheState CompareICStub::GetICState() const { |
| 352 | CompareICState::State state = Max(left(), right()); |
| 353 | switch (state) { |
| 354 | case CompareICState::UNINITIALIZED: |
| 355 | return ::v8::internal::UNINITIALIZED; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 356 | case CompareICState::BOOLEAN: |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 357 | case CompareICState::SMI: |
| 358 | case CompareICState::NUMBER: |
| 359 | case CompareICState::INTERNALIZED_STRING: |
| 360 | case CompareICState::STRING: |
| 361 | case CompareICState::UNIQUE_NAME: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 362 | case CompareICState::RECEIVER: |
| 363 | case CompareICState::KNOWN_RECEIVER: |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 364 | return MONOMORPHIC; |
| 365 | case CompareICState::GENERIC: |
| 366 | return ::v8::internal::GENERIC; |
| 367 | } |
| 368 | UNREACHABLE(); |
| 369 | return ::v8::internal::UNINITIALIZED; |
| 370 | } |
| 371 | |
| 372 | |
| 373 | Condition CompareICStub::GetCondition() const { |
| 374 | return CompareIC::ComputeCondition(op()); |
| 375 | } |
| 376 | |
| 377 | |
| 378 | void CompareICStub::AddToSpecialCache(Handle<Code> new_object) { |
| 379 | DCHECK(*known_map_ != NULL); |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 380 | Isolate* isolate = new_object->GetIsolate(); |
| 381 | Factory* factory = isolate->factory(); |
| 382 | return Map::UpdateCodeCache(known_map_, |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 383 | strict() ? |
| 384 | factory->strict_compare_ic_string() : |
| 385 | factory->compare_ic_string(), |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 386 | new_object); |
| 387 | } |
| 388 | |
| 389 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 390 | bool CompareICStub::FindCodeInSpecialCache(Code** code_out) { |
| 391 | Factory* factory = isolate()->factory(); |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 392 | Code::Flags flags = Code::ComputeFlags( |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 393 | GetCodeKind(), |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 394 | UNINITIALIZED); |
| 395 | Handle<Object> probe( |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 396 | known_map_->FindInCodeCache( |
| 397 | strict() ? |
| 398 | *factory->strict_compare_ic_string() : |
| 399 | *factory->compare_ic_string(), |
| 400 | flags), |
| 401 | isolate()); |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 402 | if (probe->IsCode()) { |
| 403 | *code_out = Code::cast(*probe); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 404 | #ifdef DEBUG |
| 405 | CompareICStub decode((*code_out)->stub_key(), isolate()); |
| 406 | DCHECK(op() == decode.op()); |
| 407 | DCHECK(left() == decode.left()); |
| 408 | DCHECK(right() == decode.right()); |
| 409 | DCHECK(state() == decode.state()); |
| 410 | #endif |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 411 | return true; |
| 412 | } |
| 413 | return false; |
| 414 | } |
| 415 | |
| 416 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 417 | void CompareICStub::Generate(MacroAssembler* masm) { |
| 418 | switch (state()) { |
| 419 | case CompareICState::UNINITIALIZED: |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 420 | GenerateMiss(masm); |
| 421 | break; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 422 | case CompareICState::BOOLEAN: |
| 423 | GenerateBooleans(masm); |
| 424 | break; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 425 | case CompareICState::SMI: |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 426 | GenerateSmis(masm); |
| 427 | break; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 428 | case CompareICState::NUMBER: |
| 429 | GenerateNumbers(masm); |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 430 | break; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 431 | case CompareICState::STRING: |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 432 | GenerateStrings(masm); |
| 433 | break; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 434 | case CompareICState::INTERNALIZED_STRING: |
| 435 | GenerateInternalizedStrings(masm); |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 436 | break; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 437 | case CompareICState::UNIQUE_NAME: |
| 438 | GenerateUniqueNames(masm); |
| 439 | break; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 440 | case CompareICState::RECEIVER: |
| 441 | GenerateReceivers(masm); |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 442 | break; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 443 | case CompareICState::KNOWN_RECEIVER: |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 444 | DCHECK(*known_map_ != NULL); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 445 | GenerateKnownReceivers(masm); |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 446 | break; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 447 | case CompareICState::GENERIC: |
| 448 | GenerateGeneric(masm); |
| 449 | break; |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 450 | } |
| 451 | } |
| 452 | |
| 453 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 454 | void CompareNilICStub::UpdateStatus(Handle<Object> object) { |
| 455 | State state = this->state(); |
| 456 | DCHECK(!state.Contains(GENERIC)); |
| 457 | State old_state = state; |
| 458 | if (object->IsNull()) { |
| 459 | state.Add(NULL_TYPE); |
| 460 | } else if (object->IsUndefined()) { |
| 461 | state.Add(UNDEFINED); |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame^] | 462 | } else if (object->IsUndetectableObject() || object->IsSmi()) { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 463 | state.RemoveAll(); |
| 464 | state.Add(GENERIC); |
| 465 | } else if (IsMonomorphic()) { |
| 466 | state.RemoveAll(); |
| 467 | state.Add(GENERIC); |
| 468 | } else { |
| 469 | state.Add(MONOMORPHIC_MAP); |
| 470 | } |
| 471 | TraceTransition(old_state, state); |
| 472 | set_sub_minor_key(TypesBits::update(sub_minor_key(), state.ToIntegral())); |
| 473 | } |
| 474 | |
| 475 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 476 | Handle<Code> TurboFanCodeStub::GenerateCode() { |
| 477 | const char* name = CodeStub::MajorName(MajorKey()); |
| 478 | Zone zone; |
| 479 | CallInterfaceDescriptor descriptor(GetCallInterfaceDescriptor()); |
| 480 | compiler::CodeStubAssembler assembler(isolate(), &zone, descriptor, |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame^] | 481 | GetCodeFlags(), name); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 482 | GenerateAssembly(&assembler); |
| 483 | return assembler.GenerateCode(); |
| 484 | } |
| 485 | |
| 486 | |
| 487 | void StringLengthStub::GenerateAssembly( |
| 488 | compiler::CodeStubAssembler* assembler) const { |
| 489 | compiler::Node* value = assembler->Parameter(0); |
| 490 | compiler::Node* string = |
| 491 | assembler->LoadObjectField(value, JSValue::kValueOffset); |
| 492 | compiler::Node* result = |
| 493 | assembler->LoadObjectField(string, String::kLengthOffset); |
| 494 | assembler->Return(result); |
| 495 | } |
| 496 | |
| 497 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 498 | template<class StateType> |
| 499 | void HydrogenCodeStub::TraceTransition(StateType from, StateType to) { |
| 500 | // Note: Although a no-op transition is semantically OK, it is hinting at a |
| 501 | // bug somewhere in our state transition machinery. |
| 502 | DCHECK(from != to); |
| 503 | if (!FLAG_trace_ic) return; |
| 504 | OFStream os(stdout); |
| 505 | os << "["; |
| 506 | PrintBaseName(os); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 507 | os << ": " << from << "=>" << to << "]" << std::endl; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 508 | } |
| 509 | |
| 510 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 511 | void CompareNilICStub::PrintBaseName(std::ostream& os) const { // NOLINT |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 512 | CodeStub::PrintBaseName(os); |
| 513 | os << ((nil_value() == kNullValue) ? "(NullValue)" : "(UndefinedValue)"); |
| 514 | } |
| 515 | |
| 516 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 517 | void CompareNilICStub::PrintState(std::ostream& os) const { // NOLINT |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 518 | os << state(); |
| 519 | } |
| 520 | |
| 521 | |
| 522 | // TODO(svenpanne) Make this a real infix_ostream_iterator. |
| 523 | class SimpleListPrinter { |
| 524 | public: |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 525 | explicit SimpleListPrinter(std::ostream& os) : os_(os), first_(true) {} |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 526 | |
| 527 | void Add(const char* s) { |
| 528 | if (first_) { |
| 529 | first_ = false; |
| 530 | } else { |
| 531 | os_ << ","; |
| 532 | } |
| 533 | os_ << s; |
Ben Murdoch | 086aeea | 2011-05-13 15:57:08 +0100 | [diff] [blame] | 534 | } |
| 535 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 536 | private: |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 537 | std::ostream& os_; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 538 | bool first_; |
| 539 | }; |
| 540 | |
| 541 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 542 | std::ostream& operator<<(std::ostream& os, const CompareNilICStub::State& s) { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 543 | os << "("; |
| 544 | SimpleListPrinter p(os); |
| 545 | if (s.IsEmpty()) p.Add("None"); |
| 546 | if (s.Contains(CompareNilICStub::UNDEFINED)) p.Add("Undefined"); |
| 547 | if (s.Contains(CompareNilICStub::NULL_TYPE)) p.Add("Null"); |
| 548 | if (s.Contains(CompareNilICStub::MONOMORPHIC_MAP)) p.Add("MonomorphicMap"); |
| 549 | if (s.Contains(CompareNilICStub::GENERIC)) p.Add("Generic"); |
| 550 | return os << ")"; |
| 551 | } |
| 552 | |
| 553 | |
| 554 | Type* CompareNilICStub::GetType(Zone* zone, Handle<Map> map) { |
| 555 | State state = this->state(); |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame^] | 556 | if (state.Contains(CompareNilICStub::GENERIC)) return Type::Any(); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 557 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame^] | 558 | Type* result = Type::None(); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 559 | if (state.Contains(CompareNilICStub::UNDEFINED)) { |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame^] | 560 | result = Type::Union(result, Type::Undefined(), zone); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 561 | } |
| 562 | if (state.Contains(CompareNilICStub::NULL_TYPE)) { |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame^] | 563 | result = Type::Union(result, Type::Null(), zone); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 564 | } |
| 565 | if (state.Contains(CompareNilICStub::MONOMORPHIC_MAP)) { |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame^] | 566 | Type* type = map.is_null() ? Type::Detectable() : Type::Class(map, zone); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 567 | result = Type::Union(result, type, zone); |
Ben Murdoch | 086aeea | 2011-05-13 15:57:08 +0100 | [diff] [blame] | 568 | } |
| 569 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 570 | return result; |
| 571 | } |
Ben Murdoch | 086aeea | 2011-05-13 15:57:08 +0100 | [diff] [blame] | 572 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 573 | |
| 574 | Type* CompareNilICStub::GetInputType(Zone* zone, Handle<Map> map) { |
| 575 | Type* output_type = GetType(zone, map); |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame^] | 576 | Type* nil_type = nil_value() == kNullValue ? Type::Null() : Type::Undefined(); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 577 | return Type::Union(output_type, nil_type, zone); |
| 578 | } |
| 579 | |
| 580 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 581 | void CallICStub::PrintState(std::ostream& os) const { // NOLINT |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 582 | os << state(); |
| 583 | } |
| 584 | |
| 585 | |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 586 | void JSEntryStub::FinishCode(Handle<Code> code) { |
| 587 | Handle<FixedArray> handler_table = |
| 588 | code->GetIsolate()->factory()->NewFixedArray(1, TENURED); |
| 589 | handler_table->set(0, Smi::FromInt(handler_offset_)); |
| 590 | code->set_handler_table(*handler_table); |
| 591 | } |
| 592 | |
| 593 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 594 | void LoadDictionaryElementStub::InitializeDescriptor( |
| 595 | CodeStubDescriptor* descriptor) { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 596 | descriptor->Initialize( |
| 597 | FUNCTION_ADDR(Runtime_KeyedLoadIC_MissFromStubFailure)); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 598 | } |
| 599 | |
| 600 | |
| 601 | void KeyedLoadGenericStub::InitializeDescriptor( |
| 602 | CodeStubDescriptor* descriptor) { |
| 603 | descriptor->Initialize( |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame^] | 604 | Runtime::FunctionForId(Runtime::kKeyedGetProperty)->entry); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 605 | } |
| 606 | |
| 607 | |
| 608 | void HandlerStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { |
| 609 | if (kind() == Code::STORE_IC) { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 610 | descriptor->Initialize(FUNCTION_ADDR(Runtime_StoreIC_MissFromStubFailure)); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 611 | } else if (kind() == Code::KEYED_LOAD_IC) { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 612 | descriptor->Initialize( |
| 613 | FUNCTION_ADDR(Runtime_KeyedLoadIC_MissFromStubFailure)); |
| 614 | } else if (kind() == Code::KEYED_STORE_IC) { |
| 615 | descriptor->Initialize( |
| 616 | FUNCTION_ADDR(Runtime_KeyedStoreIC_MissFromStubFailure)); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 617 | } |
| 618 | } |
| 619 | |
| 620 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 621 | CallInterfaceDescriptor HandlerStub::GetCallInterfaceDescriptor() const { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 622 | if (kind() == Code::LOAD_IC || kind() == Code::KEYED_LOAD_IC) { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 623 | return LoadWithVectorDescriptor(isolate()); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 624 | } else { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 625 | DCHECK(kind() == Code::STORE_IC || kind() == Code::KEYED_STORE_IC); |
| 626 | return VectorStoreICDescriptor(isolate()); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 627 | } |
| 628 | } |
| 629 | |
| 630 | |
| 631 | void StoreFastElementStub::InitializeDescriptor( |
| 632 | CodeStubDescriptor* descriptor) { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 633 | descriptor->Initialize( |
| 634 | FUNCTION_ADDR(Runtime_KeyedStoreIC_MissFromStubFailure)); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 635 | } |
| 636 | |
| 637 | |
| 638 | void ElementsTransitionAndStoreStub::InitializeDescriptor( |
| 639 | CodeStubDescriptor* descriptor) { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 640 | descriptor->Initialize( |
| 641 | FUNCTION_ADDR(Runtime_ElementsTransitionAndStoreIC_Miss)); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 642 | } |
| 643 | |
| 644 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 645 | void ToObjectStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { |
| 646 | descriptor->Initialize(Runtime::FunctionForId(Runtime::kToObject)->entry); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 647 | } |
| 648 | |
| 649 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 650 | CallInterfaceDescriptor StoreTransitionStub::GetCallInterfaceDescriptor() |
| 651 | const { |
| 652 | return VectorStoreTransitionDescriptor(isolate()); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 653 | } |
| 654 | |
| 655 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 656 | CallInterfaceDescriptor |
| 657 | ElementsTransitionAndStoreStub::GetCallInterfaceDescriptor() const { |
| 658 | return VectorStoreTransitionDescriptor(isolate()); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 659 | } |
| 660 | |
| 661 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 662 | void FastNewClosureStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 663 | descriptor->Initialize(Runtime::FunctionForId(Runtime::kNewClosure)->entry); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 664 | } |
| 665 | |
| 666 | |
| 667 | void FastNewContextStub::InitializeDescriptor(CodeStubDescriptor* d) {} |
| 668 | |
| 669 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 670 | void TypeofStub::InitializeDescriptor(CodeStubDescriptor* descriptor) {} |
| 671 | |
| 672 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 673 | void NumberToStringStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { |
| 674 | NumberToStringDescriptor call_descriptor(isolate()); |
| 675 | descriptor->Initialize( |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 676 | Runtime::FunctionForId(Runtime::kNumberToString)->entry); |
| 677 | } |
| 678 | |
| 679 | |
| 680 | void FastCloneRegExpStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { |
| 681 | FastCloneRegExpDescriptor call_descriptor(isolate()); |
| 682 | descriptor->Initialize( |
| 683 | Runtime::FunctionForId(Runtime::kCreateRegExpLiteral)->entry); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 684 | } |
| 685 | |
| 686 | |
| 687 | void FastCloneShallowArrayStub::InitializeDescriptor( |
| 688 | CodeStubDescriptor* descriptor) { |
| 689 | FastCloneShallowArrayDescriptor call_descriptor(isolate()); |
| 690 | descriptor->Initialize( |
| 691 | Runtime::FunctionForId(Runtime::kCreateArrayLiteralStubBailout)->entry); |
| 692 | } |
| 693 | |
| 694 | |
| 695 | void FastCloneShallowObjectStub::InitializeDescriptor( |
| 696 | CodeStubDescriptor* descriptor) { |
| 697 | FastCloneShallowObjectDescriptor call_descriptor(isolate()); |
| 698 | descriptor->Initialize( |
| 699 | Runtime::FunctionForId(Runtime::kCreateObjectLiteral)->entry); |
| 700 | } |
| 701 | |
| 702 | |
| 703 | void CreateAllocationSiteStub::InitializeDescriptor(CodeStubDescriptor* d) {} |
| 704 | |
| 705 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 706 | void CreateWeakCellStub::InitializeDescriptor(CodeStubDescriptor* d) {} |
| 707 | |
| 708 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 709 | void RegExpConstructResultStub::InitializeDescriptor( |
| 710 | CodeStubDescriptor* descriptor) { |
| 711 | descriptor->Initialize( |
| 712 | Runtime::FunctionForId(Runtime::kRegExpConstructResult)->entry); |
| 713 | } |
| 714 | |
| 715 | |
| 716 | void TransitionElementsKindStub::InitializeDescriptor( |
| 717 | CodeStubDescriptor* descriptor) { |
| 718 | descriptor->Initialize( |
| 719 | Runtime::FunctionForId(Runtime::kTransitionElementsKind)->entry); |
| 720 | } |
| 721 | |
| 722 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 723 | void AllocateHeapNumberStub::InitializeDescriptor( |
| 724 | CodeStubDescriptor* descriptor) { |
| 725 | descriptor->Initialize( |
| 726 | Runtime::FunctionForId(Runtime::kAllocateHeapNumber)->entry); |
| 727 | } |
| 728 | |
| 729 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 730 | void AllocateMutableHeapNumberStub::InitializeDescriptor( |
| 731 | CodeStubDescriptor* descriptor) { |
| 732 | descriptor->Initialize(); |
| 733 | } |
| 734 | |
| 735 | |
| 736 | void AllocateInNewSpaceStub::InitializeDescriptor( |
| 737 | CodeStubDescriptor* descriptor) { |
| 738 | descriptor->Initialize(); |
| 739 | } |
| 740 | |
| 741 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 742 | void CompareNilICStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 743 | descriptor->Initialize(FUNCTION_ADDR(Runtime_CompareNilIC_Miss)); |
| 744 | descriptor->SetMissHandler(ExternalReference( |
| 745 | Runtime::FunctionForId(Runtime::kCompareNilIC_Miss), isolate())); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 746 | } |
| 747 | |
| 748 | |
| 749 | void ToBooleanStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 750 | descriptor->Initialize(FUNCTION_ADDR(Runtime_ToBooleanIC_Miss)); |
| 751 | descriptor->SetMissHandler(ExternalReference( |
| 752 | Runtime::FunctionForId(Runtime::kToBooleanIC_Miss), isolate())); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 753 | } |
| 754 | |
| 755 | |
| 756 | void BinaryOpICStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 757 | descriptor->Initialize(FUNCTION_ADDR(Runtime_BinaryOpIC_Miss)); |
| 758 | descriptor->SetMissHandler(ExternalReference( |
| 759 | Runtime::FunctionForId(Runtime::kBinaryOpIC_Miss), isolate())); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 760 | } |
| 761 | |
| 762 | |
| 763 | void BinaryOpWithAllocationSiteStub::InitializeDescriptor( |
| 764 | CodeStubDescriptor* descriptor) { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 765 | descriptor->Initialize( |
| 766 | FUNCTION_ADDR(Runtime_BinaryOpIC_MissWithAllocationSite)); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 767 | } |
| 768 | |
| 769 | |
| 770 | void StringAddStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { |
| 771 | descriptor->Initialize(Runtime::FunctionForId(Runtime::kStringAdd)->entry); |
| 772 | } |
| 773 | |
| 774 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 775 | void GrowArrayElementsStub::InitializeDescriptor( |
| 776 | CodeStubDescriptor* descriptor) { |
| 777 | descriptor->Initialize( |
| 778 | Runtime::FunctionForId(Runtime::kGrowArrayElements)->entry); |
| 779 | } |
| 780 | |
| 781 | |
| 782 | void TypeofStub::GenerateAheadOfTime(Isolate* isolate) { |
| 783 | TypeofStub stub(isolate); |
| 784 | stub.GetCode(); |
| 785 | } |
| 786 | |
| 787 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 788 | void CreateAllocationSiteStub::GenerateAheadOfTime(Isolate* isolate) { |
| 789 | CreateAllocationSiteStub stub(isolate); |
| 790 | stub.GetCode(); |
| 791 | } |
| 792 | |
| 793 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 794 | void CreateWeakCellStub::GenerateAheadOfTime(Isolate* isolate) { |
| 795 | CreateWeakCellStub stub(isolate); |
| 796 | stub.GetCode(); |
| 797 | } |
| 798 | |
| 799 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 800 | void StoreElementStub::Generate(MacroAssembler* masm) { |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame^] | 801 | DCHECK_EQ(DICTIONARY_ELEMENTS, elements_kind()); |
| 802 | ElementHandlerCompiler::GenerateStoreSlow(masm); |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 803 | } |
| 804 | |
| 805 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 806 | // static |
| 807 | void StoreFastElementStub::GenerateAheadOfTime(Isolate* isolate) { |
| 808 | StoreFastElementStub(isolate, false, FAST_HOLEY_ELEMENTS, STANDARD_STORE) |
| 809 | .GetCode(); |
| 810 | StoreFastElementStub(isolate, false, FAST_HOLEY_ELEMENTS, |
| 811 | STORE_AND_GROW_NO_TRANSITION).GetCode(); |
| 812 | for (int i = FIRST_FAST_ELEMENTS_KIND; i <= LAST_FAST_ELEMENTS_KIND; i++) { |
| 813 | ElementsKind kind = static_cast<ElementsKind>(i); |
| 814 | StoreFastElementStub(isolate, true, kind, STANDARD_STORE).GetCode(); |
| 815 | StoreFastElementStub(isolate, true, kind, STORE_AND_GROW_NO_TRANSITION) |
| 816 | .GetCode(); |
| 817 | } |
| 818 | } |
| 819 | |
| 820 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 821 | void ArrayConstructorStub::PrintName(std::ostream& os) const { // NOLINT |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 822 | os << "ArrayConstructorStub"; |
| 823 | switch (argument_count()) { |
| 824 | case ANY: |
| 825 | os << "_Any"; |
| 826 | break; |
| 827 | case NONE: |
| 828 | os << "_None"; |
| 829 | break; |
| 830 | case ONE: |
| 831 | os << "_One"; |
| 832 | break; |
| 833 | case MORE_THAN_ONE: |
| 834 | os << "_More_Than_One"; |
| 835 | break; |
| 836 | } |
| 837 | return; |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame] | 838 | } |
| 839 | |
| 840 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 841 | std::ostream& ArrayConstructorStubBase::BasePrintName( |
| 842 | std::ostream& os, // NOLINT |
| 843 | const char* name) const { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 844 | os << name << "_" << ElementsKindToString(elements_kind()); |
| 845 | if (override_mode() == DISABLE_ALLOCATION_SITES) { |
| 846 | os << "_DISABLE_ALLOCATION_SITES"; |
| 847 | } |
| 848 | return os; |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame] | 849 | } |
| 850 | |
| 851 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 852 | bool ToBooleanStub::UpdateStatus(Handle<Object> object) { |
| 853 | Types new_types = types(); |
| 854 | Types old_types = new_types; |
| 855 | bool to_boolean_value = new_types.UpdateStatus(object); |
| 856 | TraceTransition(old_types, new_types); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 857 | set_sub_minor_key(TypesBits::update(sub_minor_key(), new_types.ToIntegral())); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 858 | return to_boolean_value; |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame] | 859 | } |
| 860 | |
| 861 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 862 | void ToBooleanStub::PrintState(std::ostream& os) const { // NOLINT |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 863 | os << types(); |
| 864 | } |
| 865 | |
| 866 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 867 | std::ostream& operator<<(std::ostream& os, const ToBooleanStub::Types& s) { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 868 | os << "("; |
| 869 | SimpleListPrinter p(os); |
| 870 | if (s.IsEmpty()) p.Add("None"); |
| 871 | if (s.Contains(ToBooleanStub::UNDEFINED)) p.Add("Undefined"); |
| 872 | if (s.Contains(ToBooleanStub::BOOLEAN)) p.Add("Bool"); |
| 873 | if (s.Contains(ToBooleanStub::NULL_TYPE)) p.Add("Null"); |
| 874 | if (s.Contains(ToBooleanStub::SMI)) p.Add("Smi"); |
| 875 | if (s.Contains(ToBooleanStub::SPEC_OBJECT)) p.Add("SpecObject"); |
| 876 | if (s.Contains(ToBooleanStub::STRING)) p.Add("String"); |
| 877 | if (s.Contains(ToBooleanStub::SYMBOL)) p.Add("Symbol"); |
| 878 | if (s.Contains(ToBooleanStub::HEAP_NUMBER)) p.Add("HeapNumber"); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 879 | if (s.Contains(ToBooleanStub::SIMD_VALUE)) p.Add("SimdValue"); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 880 | return os << ")"; |
| 881 | } |
| 882 | |
| 883 | |
| 884 | bool ToBooleanStub::Types::UpdateStatus(Handle<Object> object) { |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame] | 885 | if (object->IsUndefined()) { |
| 886 | Add(UNDEFINED); |
| 887 | return false; |
| 888 | } else if (object->IsBoolean()) { |
| 889 | Add(BOOLEAN); |
| 890 | return object->IsTrue(); |
| 891 | } else if (object->IsNull()) { |
| 892 | Add(NULL_TYPE); |
| 893 | return false; |
| 894 | } else if (object->IsSmi()) { |
| 895 | Add(SMI); |
| 896 | return Smi::cast(*object)->value() != 0; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 897 | } else if (object->IsJSReceiver()) { |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame] | 898 | Add(SPEC_OBJECT); |
| 899 | return !object->IsUndetectableObject(); |
| 900 | } else if (object->IsString()) { |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame^] | 901 | DCHECK(!object->IsUndetectableObject()); |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame] | 902 | Add(STRING); |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame^] | 903 | return String::cast(*object)->length() != 0; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 904 | } else if (object->IsSymbol()) { |
| 905 | Add(SYMBOL); |
| 906 | return true; |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame] | 907 | } else if (object->IsHeapNumber()) { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 908 | DCHECK(!object->IsUndetectableObject()); |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame] | 909 | Add(HEAP_NUMBER); |
| 910 | double value = HeapNumber::cast(*object)->value(); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 911 | return value != 0 && !std::isnan(value); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 912 | } else if (object->IsSimd128Value()) { |
| 913 | Add(SIMD_VALUE); |
| 914 | return true; |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame] | 915 | } else { |
| 916 | // We should never see an internal object at runtime here! |
| 917 | UNREACHABLE(); |
| 918 | return true; |
| 919 | } |
| 920 | } |
| 921 | |
| 922 | |
| 923 | bool ToBooleanStub::Types::NeedsMap() const { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 924 | return Contains(ToBooleanStub::SPEC_OBJECT) || |
| 925 | Contains(ToBooleanStub::STRING) || Contains(ToBooleanStub::SYMBOL) || |
| 926 | Contains(ToBooleanStub::HEAP_NUMBER) || |
| 927 | Contains(ToBooleanStub::SIMD_VALUE); |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame] | 928 | } |
| 929 | |
| 930 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 931 | void StubFailureTrampolineStub::GenerateAheadOfTime(Isolate* isolate) { |
| 932 | StubFailureTrampolineStub stub1(isolate, NOT_JS_FUNCTION_STUB_MODE); |
| 933 | StubFailureTrampolineStub stub2(isolate, JS_FUNCTION_STUB_MODE); |
| 934 | stub1.GetCode(); |
| 935 | stub2.GetCode(); |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 936 | } |
| 937 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 938 | |
| 939 | void ProfileEntryHookStub::EntryHookTrampoline(intptr_t function, |
| 940 | intptr_t stack_pointer, |
| 941 | Isolate* isolate) { |
| 942 | FunctionEntryHook entry_hook = isolate->function_entry_hook(); |
| 943 | DCHECK(entry_hook != NULL); |
| 944 | entry_hook(function, stack_pointer); |
| 945 | } |
| 946 | |
| 947 | |
| 948 | ArrayConstructorStub::ArrayConstructorStub(Isolate* isolate) |
| 949 | : PlatformCodeStub(isolate) { |
| 950 | minor_key_ = ArgumentCountBits::encode(ANY); |
| 951 | ArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate); |
| 952 | } |
| 953 | |
| 954 | |
| 955 | ArrayConstructorStub::ArrayConstructorStub(Isolate* isolate, |
| 956 | int argument_count) |
| 957 | : PlatformCodeStub(isolate) { |
| 958 | if (argument_count == 0) { |
| 959 | minor_key_ = ArgumentCountBits::encode(NONE); |
| 960 | } else if (argument_count == 1) { |
| 961 | minor_key_ = ArgumentCountBits::encode(ONE); |
| 962 | } else if (argument_count >= 2) { |
| 963 | minor_key_ = ArgumentCountBits::encode(MORE_THAN_ONE); |
| 964 | } else { |
| 965 | UNREACHABLE(); |
| 966 | } |
| 967 | ArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate); |
| 968 | } |
| 969 | |
| 970 | |
| 971 | InternalArrayConstructorStub::InternalArrayConstructorStub( |
| 972 | Isolate* isolate) : PlatformCodeStub(isolate) { |
| 973 | InternalArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate); |
| 974 | } |
| 975 | |
| 976 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 977 | Representation RepresentationFromType(Type* type) { |
| 978 | if (type->Is(Type::UntaggedIntegral())) { |
| 979 | return Representation::Integer32(); |
| 980 | } |
| 981 | |
| 982 | if (type->Is(Type::TaggedSigned())) { |
| 983 | return Representation::Smi(); |
| 984 | } |
| 985 | |
| 986 | if (type->Is(Type::UntaggedPointer())) { |
| 987 | return Representation::External(); |
| 988 | } |
| 989 | |
| 990 | DCHECK(!type->Is(Type::Untagged())); |
| 991 | return Representation::Tagged(); |
| 992 | } |
| 993 | |
| 994 | } // namespace internal |
| 995 | } // namespace v8 |