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

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

Issue 18807007: Fix wrong type test optimization when testing against a signature class: we must always consider th… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 5 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/code_generator.cc » ('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 "vm/exceptions.h" 7 #include "vm/exceptions.h"
8 #include "vm/heap.h" 8 #include "vm/heap.h"
9 #include "vm/native_entry.h" 9 #include "vm/native_entry.h"
10 #include "vm/object.h" 10 #include "vm/object.h"
11 #include "vm/stack_frame.h" 11 #include "vm/stack_frame.h"
12 #include "vm/symbols.h" 12 #include "vm/symbols.h"
13 13
14 namespace dart { 14 namespace dart {
15 15
16 DECLARE_FLAG(bool, enable_type_checks); 16 DECLARE_FLAG(bool, enable_type_checks);
17 DECLARE_FLAG(bool, trace_type_checks);
17 18
18 19
19 DEFINE_NATIVE_ENTRY(Object_cid, 1) { 20 DEFINE_NATIVE_ENTRY(Object_cid, 1) {
20 const Instance& instance = Instance::CheckedHandle(arguments->NativeArgAt(0)); 21 const Instance& instance = Instance::CheckedHandle(arguments->NativeArgAt(0));
21 return Smi::New(instance.GetClassId()); 22 return Smi::New(instance.GetClassId());
22 } 23 }
23 24
24 25
25 DEFINE_NATIVE_ENTRY(Object_getHash, 1) { 26 DEFINE_NATIVE_ENTRY(Object_getHash, 1) {
26 const Instance& instance = Instance::CheckedHandle(arguments->NativeArgAt(0)); 27 const Instance& instance = Instance::CheckedHandle(arguments->NativeArgAt(0));
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 StackFrame* caller_frame = iterator.NextFrame(); 121 StackFrame* caller_frame = iterator.NextFrame();
121 ASSERT(caller_frame != NULL); 122 ASSERT(caller_frame != NULL);
122 const intptr_t location = caller_frame->GetTokenPos(); 123 const intptr_t location = caller_frame->GetTokenPos();
123 String& malformed_error_message = String::Handle( 124 String& malformed_error_message = String::Handle(
124 String::New(malformed_error.ToErrorCString())); 125 String::New(malformed_error.ToErrorCString()));
125 Exceptions::CreateAndThrowTypeError( 126 Exceptions::CreateAndThrowTypeError(
126 location, Symbols::Empty(), Symbols::Empty(), 127 location, Symbols::Empty(), Symbols::Empty(),
127 Symbols::Empty(), malformed_error_message); 128 Symbols::Empty(), malformed_error_message);
128 UNREACHABLE(); 129 UNREACHABLE();
129 } 130 }
131
132 if (FLAG_trace_type_checks) {
133 const char* result_str = is_instance_of ? "true" : "false";
134 OS::Print("Object.instanceOf: result %s\n", result_str);
135 const Class& instance_class = Class::Handle(instance.clazz());
136 OS::Print(" instance [class: %s]\n",
137 String::Handle(instance_class.Name()).ToCString());
138 OS::Print(" test-type [class: %s]\n",
139 String::Handle(Class::Handle(type.type_class()).Name()).ToCString());
140 OS::Print(" type-args %s\n", instantiator_type_arguments.ToCString());
141 }
130 return Bool::Get(negate.value() ? !is_instance_of : is_instance_of); 142 return Bool::Get(negate.value() ? !is_instance_of : is_instance_of);
131 } 143 }
132 144
133 145
134 DEFINE_NATIVE_ENTRY(Object_as, 4) { 146 DEFINE_NATIVE_ENTRY(Object_as, 4) {
135 const Instance& instance = Instance::CheckedHandle(arguments->NativeArgAt(0)); 147 const Instance& instance = Instance::CheckedHandle(arguments->NativeArgAt(0));
136 // Instantiator at position 1 is not used. It is passed along so that the call 148 // Instantiator at position 1 is not used. It is passed along so that the call
137 // can be easily converted to an optimized implementation. Instantiator is 149 // can be easily converted to an optimized implementation. Instantiator is
138 // used to populate the subtype cache. 150 // used to populate the subtype cache.
139 const AbstractTypeArguments& instantiator_type_arguments = 151 const AbstractTypeArguments& instantiator_type_arguments =
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 } 201 }
190 202
191 203
192 DEFINE_NATIVE_ENTRY(AbstractType_toString, 1) { 204 DEFINE_NATIVE_ENTRY(AbstractType_toString, 1) {
193 const AbstractType& type = 205 const AbstractType& type =
194 AbstractType::CheckedHandle(arguments->NativeArgAt(0)); 206 AbstractType::CheckedHandle(arguments->NativeArgAt(0));
195 return type.UserVisibleName(); 207 return type.UserVisibleName();
196 } 208 }
197 209
198 } // namespace dart 210 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/code_generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698