OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/code-stubs.h" | 5 #include "src/code-stubs.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "src/ast/ast.h" | 9 #include "src/ast/ast.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 } | 338 } |
339 UNREACHABLE(); | 339 UNREACHABLE(); |
340 return os; | 340 return os; |
341 } | 341 } |
342 | 342 |
343 | 343 |
344 void StringAddStub::PrintBaseName(std::ostream& os) const { // NOLINT | 344 void StringAddStub::PrintBaseName(std::ostream& os) const { // NOLINT |
345 os << "StringAddStub_" << flags() << "_" << pretenure_flag(); | 345 os << "StringAddStub_" << flags() << "_" << pretenure_flag(); |
346 } | 346 } |
347 | 347 |
| 348 void StringAddStub::GenerateAssembly(CodeStubAssembler* assembler) const { |
| 349 typedef compiler::Node Node; |
| 350 Node* left = assembler->Parameter(Descriptor::kLeft); |
| 351 Node* right = assembler->Parameter(Descriptor::kRight); |
| 352 Node* context = assembler->Parameter(Descriptor::kContext); |
| 353 |
| 354 if ((flags() & STRING_ADD_CHECK_LEFT) != 0) { |
| 355 DCHECK((flags() & STRING_ADD_CONVERT) != 0); |
| 356 // TODO(danno): The ToString and JSReceiverToPrimitive below could be |
| 357 // combined to avoid duplicate smi and instance type checks. |
| 358 left = assembler->ToString(context, |
| 359 assembler->JSReceiverToPrimitive(context, left)); |
| 360 } |
| 361 if ((flags() & STRING_ADD_CHECK_RIGHT) != 0) { |
| 362 DCHECK((flags() & STRING_ADD_CONVERT) != 0); |
| 363 // TODO(danno): The ToString and JSReceiverToPrimitive below could be |
| 364 // combined to avoid duplicate smi and instance type checks. |
| 365 right = assembler->ToString( |
| 366 context, assembler->JSReceiverToPrimitive(context, right)); |
| 367 } |
| 368 |
| 369 if ((flags() & STRING_ADD_CHECK_BOTH) == 0) { |
| 370 CodeStubAssembler::AllocationFlag flags = |
| 371 (pretenure_flag() == TENURED) ? CodeStubAssembler::kPretenured |
| 372 : CodeStubAssembler::kNone; |
| 373 assembler->Return(assembler->StringAdd(context, left, right, flags)); |
| 374 } else { |
| 375 Callable callable = CodeFactory::StringAdd(isolate(), STRING_ADD_CHECK_NONE, |
| 376 pretenure_flag()); |
| 377 assembler->TailCallStub(callable, context, left, right); |
| 378 } |
| 379 } |
348 | 380 |
349 InlineCacheState CompareICStub::GetICState() const { | 381 InlineCacheState CompareICStub::GetICState() const { |
350 CompareICState::State state = Max(left(), right()); | 382 CompareICState::State state = Max(left(), right()); |
351 switch (state) { | 383 switch (state) { |
352 case CompareICState::UNINITIALIZED: | 384 case CompareICState::UNINITIALIZED: |
353 return ::v8::internal::UNINITIALIZED; | 385 return ::v8::internal::UNINITIALIZED; |
354 case CompareICState::BOOLEAN: | 386 case CompareICState::BOOLEAN: |
355 case CompareICState::SMI: | 387 case CompareICState::SMI: |
356 case CompareICState::NUMBER: | 388 case CompareICState::NUMBER: |
357 case CompareICState::INTERNALIZED_STRING: | 389 case CompareICState::INTERNALIZED_STRING: |
(...skipping 1802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2160 descriptor->SetMissHandler(Runtime::kBinaryOpIC_Miss); | 2192 descriptor->SetMissHandler(Runtime::kBinaryOpIC_Miss); |
2161 } | 2193 } |
2162 | 2194 |
2163 | 2195 |
2164 void BinaryOpWithAllocationSiteStub::InitializeDescriptor( | 2196 void BinaryOpWithAllocationSiteStub::InitializeDescriptor( |
2165 CodeStubDescriptor* descriptor) { | 2197 CodeStubDescriptor* descriptor) { |
2166 descriptor->Initialize( | 2198 descriptor->Initialize( |
2167 FUNCTION_ADDR(Runtime_BinaryOpIC_MissWithAllocationSite)); | 2199 FUNCTION_ADDR(Runtime_BinaryOpIC_MissWithAllocationSite)); |
2168 } | 2200 } |
2169 | 2201 |
2170 | |
2171 void StringAddStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { | |
2172 descriptor->Initialize(Runtime::FunctionForId(Runtime::kStringAdd)->entry); | |
2173 descriptor->SetMissHandler(Runtime::kStringAdd); | |
2174 } | |
2175 | |
2176 | |
2177 void GetPropertyStub::GenerateAssembly(CodeStubAssembler* assembler) const { | 2202 void GetPropertyStub::GenerateAssembly(CodeStubAssembler* assembler) const { |
2178 typedef compiler::Node Node; | 2203 typedef compiler::Node Node; |
2179 typedef CodeStubAssembler::Label Label; | 2204 typedef CodeStubAssembler::Label Label; |
2180 typedef CodeStubAssembler::Variable Variable; | 2205 typedef CodeStubAssembler::Variable Variable; |
2181 | 2206 |
2182 Label call_runtime(assembler, Label::kDeferred), return_undefined(assembler), | 2207 Label call_runtime(assembler, Label::kDeferred), return_undefined(assembler), |
2183 end(assembler); | 2208 end(assembler); |
2184 | 2209 |
2185 Node* object = assembler->Parameter(0); | 2210 Node* object = assembler->Parameter(0); |
2186 Node* key = assembler->Parameter(1); | 2211 Node* key = assembler->Parameter(1); |
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3037 | 3062 |
3038 if (type == MachineType::Pointer()) { | 3063 if (type == MachineType::Pointer()) { |
3039 return Representation::External(); | 3064 return Representation::External(); |
3040 } | 3065 } |
3041 | 3066 |
3042 return Representation::Tagged(); | 3067 return Representation::Tagged(); |
3043 } | 3068 } |
3044 | 3069 |
3045 } // namespace internal | 3070 } // namespace internal |
3046 } // namespace v8 | 3071 } // namespace v8 |
OLD | NEW |