OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/code_generator.h" | 5 #include "vm/code_generator.h" |
6 | 6 |
7 #include "vm/assembler.h" | 7 #include "vm/assembler.h" |
8 #include "vm/ast.h" | 8 #include "vm/ast.h" |
9 #include "vm/code_patcher.h" | 9 #include "vm/code_patcher.h" |
10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 DEFINE_RUNTIME_ENTRY(TraceFunctionExit, 1) { | 84 DEFINE_RUNTIME_ENTRY(TraceFunctionExit, 1) { |
85 const Function& function = Function::CheckedHandle(arguments.ArgAt(0)); | 85 const Function& function = Function::CheckedHandle(arguments.ArgAt(0)); |
86 const String& function_name = String::Handle(function.name()); | 86 const String& function_name = String::Handle(function.name()); |
87 const String& class_name = | 87 const String& class_name = |
88 String::Handle(Class::Handle(function.Owner()).Name()); | 88 String::Handle(Class::Handle(function.Owner()).Name()); |
89 OS::PrintErr("< Exiting '%s.%s'\n", | 89 OS::PrintErr("< Exiting '%s.%s'\n", |
90 class_name.ToCString(), function_name.ToCString()); | 90 class_name.ToCString(), function_name.ToCString()); |
91 } | 91 } |
92 | 92 |
93 | 93 |
| 94 DEFINE_RUNTIME_ENTRY(RangeError, 2) { |
| 95 const Instance& length = Instance::CheckedHandle(arguments.ArgAt(0)); |
| 96 const Instance& index = Instance::CheckedHandle(arguments.ArgAt(1)); |
| 97 if (!length.IsInteger()) { |
| 98 // Throw: new ArgumentError.value(length, "length", "is not an integer"); |
| 99 const Array& args = Array::Handle(Array::New(3)); |
| 100 args.SetAt(0, length); |
| 101 args.SetAt(1, Symbols::Length()); |
| 102 args.SetAt(2, String::Handle(String::New("is not an integer"))); |
| 103 Exceptions::ThrowByType(Exceptions::kArgumentValue, args); |
| 104 } |
| 105 if (!index.IsInteger()) { |
| 106 // Throw: new ArgumentError.value(index, "index", "is not an integer"); |
| 107 const Array& args = Array::Handle(Array::New(3)); |
| 108 args.SetAt(0, index); |
| 109 args.SetAt(1, Symbols::Index()); |
| 110 args.SetAt(2, String::Handle(String::New("is not an integer"))); |
| 111 Exceptions::ThrowByType(Exceptions::kArgumentValue, args); |
| 112 } |
| 113 // Throw: new RangeError.range(index, 0, length, "length"); |
| 114 const Array& args = Array::Handle(Array::New(4)); |
| 115 args.SetAt(0, index); |
| 116 args.SetAt(1, Integer::Handle(Integer::New(0))); |
| 117 args.SetAt(2, length); |
| 118 args.SetAt(3, Symbols::Length()); |
| 119 Exceptions::ThrowByType(Exceptions::kRange, args); |
| 120 } |
| 121 |
| 122 |
94 // Allocation of a fixed length array of given element type. | 123 // Allocation of a fixed length array of given element type. |
95 // This runtime entry is never called for allocating a List of a generic type, | 124 // This runtime entry is never called for allocating a List of a generic type, |
96 // because a prior run time call instantiates the element type if necessary. | 125 // because a prior run time call instantiates the element type if necessary. |
97 // Arg0: array length. | 126 // Arg0: array length. |
98 // Arg1: array type arguments, i.e. vector of 1 type, the element type. | 127 // Arg1: array type arguments, i.e. vector of 1 type, the element type. |
99 // Return value: newly allocated array of length arg0. | 128 // Return value: newly allocated array of length arg0. |
100 DEFINE_RUNTIME_ENTRY(AllocateArray, 2) { | 129 DEFINE_RUNTIME_ENTRY(AllocateArray, 2) { |
101 const Instance& length = Instance::CheckedHandle(arguments.ArgAt(0)); | 130 const Instance& length = Instance::CheckedHandle(arguments.ArgAt(0)); |
102 if (!length.IsInteger()) { | 131 if (!length.IsInteger()) { |
103 // Throw: new ArgumentError.value(length, "length", "is not an integer"); | 132 // Throw: new ArgumentError.value(length, "length", "is not an integer"); |
(...skipping 1826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1930 const intptr_t elm_size = old_data.ElementSizeInBytes(); | 1959 const intptr_t elm_size = old_data.ElementSizeInBytes(); |
1931 const TypedData& new_data = | 1960 const TypedData& new_data = |
1932 TypedData::Handle(TypedData::New(cid, new_size, Heap::kOld)); | 1961 TypedData::Handle(TypedData::New(cid, new_size, Heap::kOld)); |
1933 TypedData::Copy(new_data, 0, old_data, 0, old_size * elm_size); | 1962 TypedData::Copy(new_data, 0, old_data, 0, old_size * elm_size); |
1934 typed_data_cell.SetAt(0, new_data); | 1963 typed_data_cell.SetAt(0, new_data); |
1935 arguments.SetReturn(new_data); | 1964 arguments.SetReturn(new_data); |
1936 } | 1965 } |
1937 | 1966 |
1938 | 1967 |
1939 } // namespace dart | 1968 } // namespace dart |
OLD | NEW |