| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef V8_BUILTINS_BUILTINS_UTILS_H_ | 5 #ifndef V8_BUILTINS_BUILTINS_UTILS_H_ |
| 6 #define V8_BUILTINS_BUILTINS_UTILS_H_ | 6 #define V8_BUILTINS_BUILTINS_UTILS_H_ |
| 7 | 7 |
| 8 #include "src/arguments.h" | 8 #include "src/arguments.h" |
| 9 #include "src/base/logging.h" | 9 #include "src/base/logging.h" |
| 10 #include "src/builtins/builtins.h" | 10 #include "src/builtins/builtins.h" |
| 11 #include "src/code-stub-assembler.h" | 11 #include "src/code-stub-assembler.h" |
| 12 | 12 |
| 13 namespace v8 { | 13 namespace v8 { |
| 14 namespace internal { | 14 namespace internal { |
| 15 | 15 |
| 16 // Arguments object passed to C++ builtins. | 16 // Arguments object passed to C++ builtins. |
| 17 class BuiltinArguments : public Arguments { | 17 class BuiltinArguments : public Arguments { |
| 18 public: | 18 public: |
| 19 BuiltinArguments(int length, Object** arguments) | 19 BuiltinArguments(int length, Object** arguments) |
| 20 : Arguments(length, arguments) { | 20 : Arguments(length, arguments) { |
| 21 // Check we have at least the receiver. | 21 // Check we have at least the receiver. |
| 22 DCHECK_LE(1, this->length()); | 22 DCHECK_LE(1, this->length()); |
| 23 } | 23 } |
| 24 | 24 |
| 25 Object*& operator[](int index) { | 25 Object*& operator[](int index) { |
| 26 DCHECK_LT(index, length()); | 26 DCHECK_LT(index, length()); |
| 27 return Arguments::operator[](index); | 27 return Arguments::operator[](index); |
| 28 } | 28 } |
| 29 | 29 |
| 30 template <class S> | 30 template <class S = Object> |
| 31 Handle<S> at(int index) { | 31 Handle<S> at(int index) { |
| 32 DCHECK_LT(index, length()); | 32 DCHECK_LT(index, length()); |
| 33 return Arguments::at<S>(index); | 33 return Arguments::at<S>(index); |
| 34 } | 34 } |
| 35 | 35 |
| 36 Handle<Object> atOrUndefined(Isolate* isolate, int index) { | 36 Handle<Object> atOrUndefined(Isolate* isolate, int index) { |
| 37 if (index >= length()) { | 37 if (index >= length()) { |
| 38 return isolate->factory()->undefined_value(); | 38 return isolate->factory()->undefined_value(); |
| 39 } | 39 } |
| 40 return at<Object>(index); | 40 return at<Object>(index); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 isolate->factory()->NewStringFromAsciiChecked(method))); \ | 150 isolate->factory()->NewStringFromAsciiChecked(method))); \ |
| 151 } \ | 151 } \ |
| 152 Handle<String> name; \ | 152 Handle<String> name; \ |
| 153 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( \ | 153 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( \ |
| 154 isolate, name, Object::ToString(isolate, args.receiver())) | 154 isolate, name, Object::ToString(isolate, args.receiver())) |
| 155 | 155 |
| 156 } // namespace internal | 156 } // namespace internal |
| 157 } // namespace v8 | 157 } // namespace v8 |
| 158 | 158 |
| 159 #endif // V8_BUILTINS_BUILTINS_UTILS_H_ | 159 #endif // V8_BUILTINS_BUILTINS_UTILS_H_ |
| OLD | NEW |