Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(418)

Side by Side Diff: runtime/lib/object.cc

Issue 308513005: Intrinsify [] for ExternalUint8 and Uint8 typed data. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/intrinsifier.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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/bootstrap_natives.h" 5 #include "vm/bootstrap_natives.h"
6 6
7 #include "lib/invocation_mirror.h" 7 #include "lib/invocation_mirror.h"
8 #include "vm/code_patcher.h" 8 #include "vm/code_patcher.h"
9 #include "vm/exceptions.h" 9 #include "vm/exceptions.h"
10 #include "vm/heap.h" 10 #include "vm/heap.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 } else { 155 } else {
156 ASSERT(instance_is_int); 156 ASSERT(instance_is_int);
157 if (instantiated_type.IsDoubleType()) { 157 if (instantiated_type.IsDoubleType()) {
158 JSWarning("integer value is also considered to be of type 'double'"); 158 JSWarning("integer value is also considered to be of type 'double'");
159 } 159 }
160 } 160 }
161 } 161 }
162 162
163 163
164 DEFINE_NATIVE_ENTRY(Object_instanceOf, 5) { 164 DEFINE_NATIVE_ENTRY(Object_instanceOf, 5) {
165 const Instance& instance = Instance::CheckedHandle(arguments->NativeArgAt(0)); 165 const Instance& instance =
166 Instance::CheckedHandle(isolate, arguments->NativeArgAt(0));
166 // Instantiator at position 1 is not used. It is passed along so that the call 167 // Instantiator at position 1 is not used. It is passed along so that the call
167 // can be easily converted to an optimized implementation. Instantiator is 168 // can be easily converted to an optimized implementation. Instantiator is
168 // used to populate the subtype cache. 169 // used to populate the subtype cache.
169 const TypeArguments& instantiator_type_arguments = 170 const TypeArguments& instantiator_type_arguments =
170 TypeArguments::CheckedHandle(arguments->NativeArgAt(2)); 171 TypeArguments::CheckedHandle(isolate, arguments->NativeArgAt(2));
171 const AbstractType& type = 172 const AbstractType& type =
172 AbstractType::CheckedHandle(arguments->NativeArgAt(3)); 173 AbstractType::CheckedHandle(isolate, arguments->NativeArgAt(3));
173 const Bool& negate = Bool::CheckedHandle(arguments->NativeArgAt(4)); 174 const Bool& negate = Bool::CheckedHandle(isolate, arguments->NativeArgAt(4));
174 ASSERT(type.IsFinalized()); 175 ASSERT(type.IsFinalized());
175 ASSERT(!type.IsMalformed()); 176 ASSERT(!type.IsMalformed());
176 ASSERT(!type.IsMalbounded()); 177 ASSERT(!type.IsMalbounded());
177 178
178 // Check for javascript compatibility. 179 // Check for javascript compatibility.
179 if (FLAG_warn_on_javascript_compatibility) { 180 if (FLAG_warn_on_javascript_compatibility) {
180 WarnOnJSIntegralNumTypeTest(instance, instantiator_type_arguments, type); 181 WarnOnJSIntegralNumTypeTest(instance, instantiator_type_arguments, type);
181 } 182 }
182 183
183 Error& bound_error = Error::Handle(); 184 Error& bound_error = Error::Handle(isolate, Error::null());
184 const bool is_instance_of = instance.IsInstanceOf(type, 185 const bool is_instance_of = instance.IsInstanceOf(type,
185 instantiator_type_arguments, 186 instantiator_type_arguments,
186 &bound_error); 187 &bound_error);
187 if (FLAG_trace_type_checks) { 188 if (FLAG_trace_type_checks) {
188 const char* result_str = is_instance_of ? "true" : "false"; 189 const char* result_str = is_instance_of ? "true" : "false";
189 OS::Print("Native Object.instanceOf: result %s\n", result_str); 190 OS::Print("Native Object.instanceOf: result %s\n", result_str);
190 const Type& instance_type = Type::Handle(instance.GetType()); 191 const Type& instance_type = Type::Handle(instance.GetType());
191 OS::Print(" instance type: %s\n", 192 OS::Print(" instance type: %s\n",
192 String::Handle(instance_type.Name()).ToCString()); 193 String::Handle(instance_type.Name()).ToCString());
193 OS::Print(" test type: %s\n", String::Handle(type.Name()).ToCString()); 194 OS::Print(" test type: %s\n", String::Handle(type.Name()).ToCString());
194 if (!bound_error.IsNull()) { 195 if (!bound_error.IsNull()) {
195 OS::Print(" bound error: %s\n", bound_error.ToErrorCString()); 196 OS::Print(" bound error: %s\n", bound_error.ToErrorCString());
196 } 197 }
197 } 198 }
198 if (!is_instance_of && !bound_error.IsNull()) { 199 if (!is_instance_of && !bound_error.IsNull()) {
199 // Throw a dynamic type error only if the instanceof test fails. 200 // Throw a dynamic type error only if the instanceof test fails.
200 DartFrameIterator iterator; 201 DartFrameIterator iterator;
201 StackFrame* caller_frame = iterator.NextFrame(); 202 StackFrame* caller_frame = iterator.NextFrame();
202 ASSERT(caller_frame != NULL); 203 ASSERT(caller_frame != NULL);
203 const intptr_t location = caller_frame->GetTokenPos(); 204 const intptr_t location = caller_frame->GetTokenPos();
204 String& bound_error_message = String::Handle( 205 String& bound_error_message = String::Handle(
205 String::New(bound_error.ToErrorCString())); 206 isolate, String::New(bound_error.ToErrorCString()));
206 Exceptions::CreateAndThrowTypeError( 207 Exceptions::CreateAndThrowTypeError(
207 location, Symbols::Empty(), Symbols::Empty(), 208 location, Symbols::Empty(), Symbols::Empty(),
208 Symbols::Empty(), bound_error_message); 209 Symbols::Empty(), bound_error_message);
209 UNREACHABLE(); 210 UNREACHABLE();
210 } 211 }
211 return Bool::Get(negate.value() ? !is_instance_of : is_instance_of).raw(); 212 return Bool::Get(negate.value() ? !is_instance_of : is_instance_of).raw();
212 } 213 }
213 214
214 215
215 DEFINE_NATIVE_ENTRY(Object_as, 4) { 216 DEFINE_NATIVE_ENTRY(Object_as, 4) {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 297
297 298
298 DEFINE_NATIVE_ENTRY(LibraryPrefix_load, 1) { 299 DEFINE_NATIVE_ENTRY(LibraryPrefix_load, 1) {
299 const LibraryPrefix& prefix = 300 const LibraryPrefix& prefix =
300 LibraryPrefix::CheckedHandle(arguments->NativeArgAt(0)); 301 LibraryPrefix::CheckedHandle(arguments->NativeArgAt(0));
301 prefix.LoadLibrary(); 302 prefix.LoadLibrary();
302 return Bool::Get(true).raw(); 303 return Bool::Get(true).raw();
303 } 304 }
304 305
305 } // namespace dart 306 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/intrinsifier.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698