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/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
(...skipping 2965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2976 | 2976 |
2977 assembler->Bind(&if_valueisundetectable); | 2977 assembler->Bind(&if_valueisundetectable); |
2978 assembler->Return(assembler->BooleanConstant(false)); | 2978 assembler->Return(assembler->BooleanConstant(false)); |
2979 | 2979 |
2980 assembler->Bind(&if_valueisnotundetectable); | 2980 assembler->Bind(&if_valueisnotundetectable); |
2981 assembler->Return(assembler->BooleanConstant(true)); | 2981 assembler->Return(assembler->BooleanConstant(true)); |
2982 } | 2982 } |
2983 } | 2983 } |
2984 } | 2984 } |
2985 | 2985 |
| 2986 void ToIntegerStub::GenerateAssembly( |
| 2987 compiler::CodeStubAssembler* assembler) const { |
| 2988 typedef compiler::CodeStubAssembler::Label Label; |
| 2989 typedef compiler::Node Node; |
| 2990 typedef compiler::CodeStubAssembler::Variable Variable; |
| 2991 |
| 2992 Node* context = assembler->Parameter(1); |
| 2993 |
| 2994 // We might need to loop once for ToNumber conversion. |
| 2995 Variable var_arg(assembler, MachineRepresentation::kTagged); |
| 2996 Label loop(assembler, &var_arg); |
| 2997 var_arg.Bind(assembler->Parameter(0)); |
| 2998 assembler->Goto(&loop); |
| 2999 assembler->Bind(&loop); |
| 3000 { |
| 3001 // Shared entry points. |
| 3002 Label return_arg(assembler), return_zero(assembler, Label::kDeferred); |
| 3003 |
| 3004 // Load the current {arg} value. |
| 3005 Node* arg = var_arg.value(); |
| 3006 |
| 3007 // Check if {arg} is a Smi. |
| 3008 assembler->GotoIf(assembler->WordIsSmi(arg), &return_arg); |
| 3009 |
| 3010 // Check if {arg} is a HeapNumber. |
| 3011 Label if_argisheapnumber(assembler), |
| 3012 if_argisnotheapnumber(assembler, Label::kDeferred); |
| 3013 assembler->Branch(assembler->WordEqual(assembler->LoadMap(arg), |
| 3014 assembler->HeapNumberMapConstant()), |
| 3015 &if_argisheapnumber, &if_argisnotheapnumber); |
| 3016 |
| 3017 assembler->Bind(&if_argisheapnumber); |
| 3018 { |
| 3019 // Load the floating-point value of {arg}. |
| 3020 Node* arg_value = assembler->LoadHeapNumberValue(arg); |
| 3021 |
| 3022 // Check if {arg} is NaN. |
| 3023 assembler->GotoUnless(assembler->Float64Equal(arg_value, arg_value), |
| 3024 &return_zero); |
| 3025 |
| 3026 // Truncate {arg} towards zero. |
| 3027 Node* value = assembler->Float64Trunc(arg_value); |
| 3028 var_arg.Bind(assembler->ChangeFloat64ToTagged(value)); |
| 3029 assembler->Goto(&return_arg); |
| 3030 } |
| 3031 |
| 3032 assembler->Bind(&if_argisnotheapnumber); |
| 3033 { |
| 3034 // Need to convert {arg} to a Number first. |
| 3035 Callable callable = CodeFactory::NonNumberToNumber(assembler->isolate()); |
| 3036 var_arg.Bind(assembler->CallStub(callable, context, arg)); |
| 3037 assembler->Goto(&loop); |
| 3038 } |
| 3039 |
| 3040 assembler->Bind(&return_arg); |
| 3041 assembler->Return(var_arg.value()); |
| 3042 |
| 3043 assembler->Bind(&return_zero); |
| 3044 assembler->Return(assembler->SmiConstant(Smi::FromInt(0))); |
| 3045 } |
| 3046 } |
| 3047 |
2986 void StoreInterceptorStub::GenerateAssembly( | 3048 void StoreInterceptorStub::GenerateAssembly( |
2987 compiler::CodeStubAssembler* assembler) const { | 3049 compiler::CodeStubAssembler* assembler) const { |
2988 typedef compiler::Node Node; | 3050 typedef compiler::Node Node; |
2989 Node* receiver = assembler->Parameter(0); | 3051 Node* receiver = assembler->Parameter(0); |
2990 Node* name = assembler->Parameter(1); | 3052 Node* name = assembler->Parameter(1); |
2991 Node* value = assembler->Parameter(2); | 3053 Node* value = assembler->Parameter(2); |
2992 Node* context = assembler->Parameter(3); | 3054 Node* context = assembler->Parameter(3); |
2993 assembler->TailCallRuntime(Runtime::kStorePropertyWithInterceptor, context, | 3055 assembler->TailCallRuntime(Runtime::kStorePropertyWithInterceptor, context, |
2994 receiver, name, value); | 3056 receiver, name, value); |
2995 } | 3057 } |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3452 if (type->Is(Type::UntaggedPointer())) { | 3514 if (type->Is(Type::UntaggedPointer())) { |
3453 return Representation::External(); | 3515 return Representation::External(); |
3454 } | 3516 } |
3455 | 3517 |
3456 DCHECK(!type->Is(Type::Untagged())); | 3518 DCHECK(!type->Is(Type::Untagged())); |
3457 return Representation::Tagged(); | 3519 return Representation::Tagged(); |
3458 } | 3520 } |
3459 | 3521 |
3460 } // namespace internal | 3522 } // namespace internal |
3461 } // namespace v8 | 3523 } // namespace v8 |
OLD | NEW |