1 // Copyright 2018 the V8 project authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef V8_EXECUTION_ARGUMENTS_INL_H_ 6 #define V8_EXECUTION_ARGUMENTS_INL_H_ 7 8 #include "src/execution/arguments.h" 9 10 #include "src/handles/handles-inl.h" 11 #include "src/objects/objects-inl.h" // TODO(jkummerow): Just smi-inl.h. 12 #include "src/objects/tagged-index.h" 13 14 namespace v8 { 15 namespace internal { 16 17 template <ArgumentsType T> ChangeValueScope(Isolate * isolate,Arguments * args,int index,Object value)18Arguments<T>::ChangeValueScope::ChangeValueScope(Isolate* isolate, 19 Arguments* args, int index, 20 Object value) 21 : location_(args->address_of_arg_at(index)) { 22 old_value_ = handle(Object(*location_), isolate); 23 *location_ = value.ptr(); 24 } 25 26 template <ArgumentsType T> smi_value_at(int index)27int Arguments<T>::smi_value_at(int index) const { 28 Object obj = (*this)[index]; 29 int value = Smi::ToInt(obj); 30 DCHECK_IMPLIES(obj.IsTaggedIndex(), value == tagged_index_value_at(index)); 31 return value; 32 } 33 34 template <ArgumentsType T> positive_smi_value_at(int index)35uint32_t Arguments<T>::positive_smi_value_at(int index) const { 36 int value = smi_value_at(index); 37 DCHECK_LE(0, value); 38 return value; 39 } 40 41 template <ArgumentsType T> tagged_index_value_at(int index)42int Arguments<T>::tagged_index_value_at(int index) const { 43 return static_cast<int>(TaggedIndex::cast((*this)[index]).value()); 44 } 45 46 template <ArgumentsType T> number_value_at(int index)47double Arguments<T>::number_value_at(int index) const { 48 return (*this)[index].Number(); 49 } 50 51 } // namespace internal 52 } // namespace v8 53 54 #endif // V8_EXECUTION_ARGUMENTS_INL_H_ 55