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

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

Issue 1012333002: Keep zone cached in SnapshotReader to allow removing ZoneHandle(Isolate*) interface. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 9 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 | « runtime/lib/function.cc ('k') | runtime/lib/string.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 "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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 Report::JSWarningFromNative( 151 Report::JSWarningFromNative(
152 false, // Object_instanceOf and Object_as are not static calls. 152 false, // Object_instanceOf and Object_as are not static calls.
153 "integer value is also considered to be of type 'double'"); 153 "integer value is also considered to be of type 'double'");
154 } 154 }
155 } 155 }
156 } 156 }
157 157
158 158
159 DEFINE_NATIVE_ENTRY(Object_instanceOf, 5) { 159 DEFINE_NATIVE_ENTRY(Object_instanceOf, 5) {
160 const Instance& instance = 160 const Instance& instance =
161 Instance::CheckedHandle(isolate, arguments->NativeArgAt(0)); 161 Instance::CheckedHandle(zone, arguments->NativeArgAt(0));
162 // Instantiator at position 1 is not used. It is passed along so that the call 162 // Instantiator at position 1 is not used. It is passed along so that the call
163 // can be easily converted to an optimized implementation. Instantiator is 163 // can be easily converted to an optimized implementation. Instantiator is
164 // used to populate the subtype cache. 164 // used to populate the subtype cache.
165 const TypeArguments& instantiator_type_arguments = 165 const TypeArguments& instantiator_type_arguments =
166 TypeArguments::CheckedHandle(isolate, arguments->NativeArgAt(2)); 166 TypeArguments::CheckedHandle(zone, arguments->NativeArgAt(2));
167 const AbstractType& type = 167 const AbstractType& type =
168 AbstractType::CheckedHandle(isolate, arguments->NativeArgAt(3)); 168 AbstractType::CheckedHandle(zone, arguments->NativeArgAt(3));
169 const Bool& negate = Bool::CheckedHandle(isolate, arguments->NativeArgAt(4)); 169 const Bool& negate = Bool::CheckedHandle(zone, arguments->NativeArgAt(4));
170 ASSERT(type.IsFinalized()); 170 ASSERT(type.IsFinalized());
171 ASSERT(!type.IsMalformed()); 171 ASSERT(!type.IsMalformed());
172 ASSERT(!type.IsMalbounded()); 172 ASSERT(!type.IsMalbounded());
173 173
174 // Check for javascript compatibility. 174 // Check for javascript compatibility.
175 if (FLAG_warn_on_javascript_compatibility) { 175 if (FLAG_warn_on_javascript_compatibility) {
176 WarnOnJSIntegralNumTypeTest(instance, instantiator_type_arguments, type); 176 WarnOnJSIntegralNumTypeTest(instance, instantiator_type_arguments, type);
177 } 177 }
178 178
179 Error& bound_error = Error::Handle(isolate, Error::null()); 179 Error& bound_error = Error::Handle(zone, Error::null());
180 const bool is_instance_of = instance.IsInstanceOf(type, 180 const bool is_instance_of = instance.IsInstanceOf(type,
181 instantiator_type_arguments, 181 instantiator_type_arguments,
182 &bound_error); 182 &bound_error);
183 if (FLAG_trace_type_checks) { 183 if (FLAG_trace_type_checks) {
184 const char* result_str = is_instance_of ? "true" : "false"; 184 const char* result_str = is_instance_of ? "true" : "false";
185 OS::Print("Native Object.instanceOf: result %s\n", result_str); 185 OS::Print("Native Object.instanceOf: result %s\n", result_str);
186 const Type& instance_type = Type::Handle(instance.GetType()); 186 const Type& instance_type = Type::Handle(instance.GetType());
187 OS::Print(" instance type: %s\n", 187 OS::Print(" instance type: %s\n",
188 String::Handle(instance_type.Name()).ToCString()); 188 String::Handle(instance_type.Name()).ToCString());
189 OS::Print(" test type: %s\n", String::Handle(type.Name()).ToCString()); 189 OS::Print(" test type: %s\n", String::Handle(type.Name()).ToCString());
190 if (!bound_error.IsNull()) { 190 if (!bound_error.IsNull()) {
191 OS::Print(" bound error: %s\n", bound_error.ToErrorCString()); 191 OS::Print(" bound error: %s\n", bound_error.ToErrorCString());
192 } 192 }
193 } 193 }
194 if (!is_instance_of && !bound_error.IsNull()) { 194 if (!is_instance_of && !bound_error.IsNull()) {
195 // Throw a dynamic type error only if the instanceof test fails. 195 // Throw a dynamic type error only if the instanceof test fails.
196 DartFrameIterator iterator; 196 DartFrameIterator iterator;
197 StackFrame* caller_frame = iterator.NextFrame(); 197 StackFrame* caller_frame = iterator.NextFrame();
198 ASSERT(caller_frame != NULL); 198 ASSERT(caller_frame != NULL);
199 const intptr_t location = caller_frame->GetTokenPos(); 199 const intptr_t location = caller_frame->GetTokenPos();
200 String& bound_error_message = String::Handle( 200 String& bound_error_message = String::Handle(
201 isolate, String::New(bound_error.ToErrorCString())); 201 zone, String::New(bound_error.ToErrorCString()));
202 Exceptions::CreateAndThrowTypeError( 202 Exceptions::CreateAndThrowTypeError(
203 location, Symbols::Empty(), Symbols::Empty(), 203 location, Symbols::Empty(), Symbols::Empty(),
204 Symbols::Empty(), bound_error_message); 204 Symbols::Empty(), bound_error_message);
205 UNREACHABLE(); 205 UNREACHABLE();
206 } 206 }
207 return Bool::Get(negate.value() ? !is_instance_of : is_instance_of).raw(); 207 return Bool::Get(negate.value() ? !is_instance_of : is_instance_of).raw();
208 } 208 }
209 209
210 210
211 DEFINE_NATIVE_ENTRY(Object_as, 4) { 211 DEFINE_NATIVE_ENTRY(Object_as, 4) {
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 // Currently all errors are Dart instances, e.g. I/O errors 313 // Currently all errors are Dart instances, e.g. I/O errors
314 // created by deferred loading code. LanguageErrors from 314 // created by deferred loading code. LanguageErrors from
315 // failed loading or finalization attempts are propagated and result 315 // failed loading or finalization attempts are propagated and result
316 // in the isolate's death. 316 // in the isolate's death.
317 const Instance& error = Instance::Handle(prefix.LoadError()); 317 const Instance& error = Instance::Handle(prefix.LoadError());
318 return error.raw(); 318 return error.raw();
319 } 319 }
320 320
321 321
322 } // namespace dart 322 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/lib/function.cc ('k') | runtime/lib/string.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698