| 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 <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "src/bailout-reason.h" | 9 #include "src/bailout-reason.h" |
| 10 #include "src/crankshaft/hydrogen.h" | 10 #include "src/crankshaft/hydrogen.h" |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 info()->MarkAsSavesCallerDoubles(); | 332 info()->MarkAsSavesCallerDoubles(); |
| 333 HValue* number = GetParameter(Descriptor::kArgument); | 333 HValue* number = GetParameter(Descriptor::kArgument); |
| 334 return BuildNumberToString(number, AstType::Number()); | 334 return BuildNumberToString(number, AstType::Number()); |
| 335 } | 335 } |
| 336 | 336 |
| 337 | 337 |
| 338 Handle<Code> NumberToStringStub::GenerateCode() { | 338 Handle<Code> NumberToStringStub::GenerateCode() { |
| 339 return DoGenerateCode(this); | 339 return DoGenerateCode(this); |
| 340 } | 340 } |
| 341 | 341 |
| 342 | |
| 343 template <> | |
| 344 HValue* CodeStubGraphBuilder<FastCloneShallowArrayStub>::BuildCodeStub() { | |
| 345 Factory* factory = isolate()->factory(); | |
| 346 HValue* undefined = graph()->GetConstantUndefined(); | |
| 347 AllocationSiteMode alloc_site_mode = casted_stub()->allocation_site_mode(); | |
| 348 HValue* closure = GetParameter(Descriptor::kClosure); | |
| 349 HValue* literal_index = GetParameter(Descriptor::kLiteralIndex); | |
| 350 | |
| 351 // TODO(turbofan): This codestub has regressed to need a frame on ia32 at some | |
| 352 // point and wasn't caught since it wasn't built in the snapshot. We should | |
| 353 // probably just replace with a TurboFan stub rather than fixing it. | |
| 354 #if !(V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87) | |
| 355 // This stub is very performance sensitive, the generated code must be tuned | |
| 356 // so that it doesn't build and eager frame. | |
| 357 info()->MarkMustNotHaveEagerFrame(); | |
| 358 #endif | |
| 359 | |
| 360 HValue* literals_array = Add<HLoadNamedField>( | |
| 361 closure, nullptr, HObjectAccess::ForLiteralsPointer()); | |
| 362 | |
| 363 HInstruction* allocation_site = Add<HLoadKeyed>( | |
| 364 literals_array, literal_index, nullptr, nullptr, FAST_ELEMENTS, | |
| 365 NEVER_RETURN_HOLE, LiteralsArray::kOffsetToFirstLiteral - kHeapObjectTag); | |
| 366 IfBuilder checker(this); | |
| 367 checker.IfNot<HCompareObjectEqAndBranch, HValue*>(allocation_site, | |
| 368 undefined); | |
| 369 checker.Then(); | |
| 370 | |
| 371 HObjectAccess access = HObjectAccess::ForAllocationSiteOffset( | |
| 372 AllocationSite::kTransitionInfoOffset); | |
| 373 HInstruction* boilerplate = | |
| 374 Add<HLoadNamedField>(allocation_site, nullptr, access); | |
| 375 HValue* elements = AddLoadElements(boilerplate); | |
| 376 HValue* capacity = AddLoadFixedArrayLength(elements); | |
| 377 IfBuilder zero_capacity(this); | |
| 378 zero_capacity.If<HCompareNumericAndBranch>(capacity, graph()->GetConstant0(), | |
| 379 Token::EQ); | |
| 380 zero_capacity.Then(); | |
| 381 Push(BuildCloneShallowArrayEmpty(boilerplate, | |
| 382 allocation_site, | |
| 383 alloc_site_mode)); | |
| 384 zero_capacity.Else(); | |
| 385 IfBuilder if_fixed_cow(this); | |
| 386 if_fixed_cow.If<HCompareMap>(elements, factory->fixed_cow_array_map()); | |
| 387 if_fixed_cow.Then(); | |
| 388 Push(BuildCloneShallowArrayCow(boilerplate, | |
| 389 allocation_site, | |
| 390 alloc_site_mode, | |
| 391 FAST_ELEMENTS)); | |
| 392 if_fixed_cow.Else(); | |
| 393 IfBuilder if_fixed(this); | |
| 394 if_fixed.If<HCompareMap>(elements, factory->fixed_array_map()); | |
| 395 if_fixed.Then(); | |
| 396 Push(BuildCloneShallowArrayNonEmpty(boilerplate, | |
| 397 allocation_site, | |
| 398 alloc_site_mode, | |
| 399 FAST_ELEMENTS)); | |
| 400 | |
| 401 if_fixed.Else(); | |
| 402 Push(BuildCloneShallowArrayNonEmpty(boilerplate, | |
| 403 allocation_site, | |
| 404 alloc_site_mode, | |
| 405 FAST_DOUBLE_ELEMENTS)); | |
| 406 if_fixed.End(); | |
| 407 if_fixed_cow.End(); | |
| 408 zero_capacity.End(); | |
| 409 | |
| 410 checker.ElseDeopt(DeoptimizeReason::kUninitializedBoilerplateLiterals); | |
| 411 checker.End(); | |
| 412 | |
| 413 return environment()->Pop(); | |
| 414 } | |
| 415 | |
| 416 | |
| 417 Handle<Code> FastCloneShallowArrayStub::GenerateCode() { | |
| 418 return DoGenerateCode(this); | |
| 419 } | |
| 420 | |
| 421 HValue* CodeStubGraphBuilderBase::BuildPushElement(HValue* object, HValue* argc, | 342 HValue* CodeStubGraphBuilderBase::BuildPushElement(HValue* object, HValue* argc, |
| 422 HValue* argument_elements, | 343 HValue* argument_elements, |
| 423 ElementsKind kind) { | 344 ElementsKind kind) { |
| 424 // Precheck whether all elements fit into the array. | 345 // Precheck whether all elements fit into the array. |
| 425 if (!IsFastObjectElementsKind(kind)) { | 346 if (!IsFastObjectElementsKind(kind)) { |
| 426 LoopBuilder builder(this, context(), LoopBuilder::kPostIncrement); | 347 LoopBuilder builder(this, context(), LoopBuilder::kPostIncrement); |
| 427 HValue* start = graph()->GetConstant0(); | 348 HValue* start = graph()->GetConstant0(); |
| 428 HValue* key = builder.BeginBody(start, argc, Token::LT); | 349 HValue* key = builder.BeginBody(start, argc, Token::LT); |
| 429 { | 350 { |
| 430 HInstruction* argument = | 351 HInstruction* argument = |
| (...skipping 30 matching lines...) Expand all Loading... |
| 461 AddElementAccess(elements, index, argument, object, nullptr, kind, STORE); | 382 AddElementAccess(elements, index, argument, object, nullptr, kind, STORE); |
| 462 } | 383 } |
| 463 builder.EndBody(); | 384 builder.EndBody(); |
| 464 return new_length; | 385 return new_length; |
| 465 } | 386 } |
| 466 | 387 |
| 467 template <> | 388 template <> |
| 468 HValue* CodeStubGraphBuilder<FastArrayPushStub>::BuildCodeStub() { | 389 HValue* CodeStubGraphBuilder<FastArrayPushStub>::BuildCodeStub() { |
| 469 // TODO(verwaest): Fix deoptimizer messages. | 390 // TODO(verwaest): Fix deoptimizer messages. |
| 470 HValue* argc = GetArgumentsLength(); | 391 HValue* argc = GetArgumentsLength(); |
| 392 |
| 471 HInstruction* argument_elements = Add<HArgumentsElements>(false, false); | 393 HInstruction* argument_elements = Add<HArgumentsElements>(false, false); |
| 472 HInstruction* object = Add<HAccessArgumentsAt>(argument_elements, argc, | 394 HInstruction* object = Add<HAccessArgumentsAt>(argument_elements, argc, |
| 473 graph()->GetConstantMinus1()); | 395 graph()->GetConstantMinus1()); |
| 474 BuildCheckHeapObject(object); | 396 BuildCheckHeapObject(object); |
| 475 HValue* map = Add<HLoadNamedField>(object, nullptr, HObjectAccess::ForMap()); | 397 HValue* map = Add<HLoadNamedField>(object, nullptr, HObjectAccess::ForMap()); |
| 476 Add<HCheckInstanceType>(object, HCheckInstanceType::IS_JS_ARRAY); | 398 Add<HCheckInstanceType>(object, HCheckInstanceType::IS_JS_ARRAY); |
| 477 | 399 |
| 478 // Disallow pushing onto prototypes. It might be the JSArray prototype. | 400 // Disallow pushing onto prototypes. It might be the JSArray prototype. |
| 479 // Disallow pushing onto non-extensible objects. | 401 // Disallow pushing onto non-extensible objects. |
| 480 { | 402 { |
| (...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1536 return Pop(); | 1458 return Pop(); |
| 1537 } | 1459 } |
| 1538 | 1460 |
| 1539 | 1461 |
| 1540 Handle<Code> KeyedLoadGenericStub::GenerateCode() { | 1462 Handle<Code> KeyedLoadGenericStub::GenerateCode() { |
| 1541 return DoGenerateCode(this); | 1463 return DoGenerateCode(this); |
| 1542 } | 1464 } |
| 1543 | 1465 |
| 1544 } // namespace internal | 1466 } // namespace internal |
| 1545 } // namespace v8 | 1467 } // namespace v8 |
| OLD | NEW |