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

Side by Side Diff: vm/code_generator.cc

Issue 11667012: Convert all symbols accessor to return read only handles so that it is not necessary to create a ne… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 7 years, 11 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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_macros.h" 7 #include "vm/assembler_macros.h"
8 #include "vm/ast.h" 8 #include "vm/ast.h"
9 #include "vm/bigint_operations.h" 9 #include "vm/bigint_operations.h"
10 #include "vm/code_patcher.h" 10 #include "vm/code_patcher.h"
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 ASSERT(type_arguments.IsInstantiated()); 227 ASSERT(type_arguments.IsInstantiated());
228 Error& malformed_error = Error::Handle(); 228 Error& malformed_error = Error::Handle();
229 if (!type_arguments.IsWithinBoundsOf(cls, 229 if (!type_arguments.IsWithinBoundsOf(cls,
230 bounds_instantiator, 230 bounds_instantiator,
231 &malformed_error)) { 231 &malformed_error)) {
232 ASSERT(!malformed_error.IsNull()); 232 ASSERT(!malformed_error.IsNull());
233 // Throw a dynamic type error. 233 // Throw a dynamic type error.
234 const intptr_t location = GetCallerLocation(); 234 const intptr_t location = GetCallerLocation();
235 String& malformed_error_message = String::Handle( 235 String& malformed_error_message = String::Handle(
236 String::New(malformed_error.ToErrorCString())); 236 String::New(malformed_error.ToErrorCString()));
237 const String& no_name = String::Handle(Symbols::Empty());
238 Exceptions::CreateAndThrowTypeError( 237 Exceptions::CreateAndThrowTypeError(
239 location, no_name, no_name, no_name, malformed_error_message); 238 location, Symbols::Empty(), Symbols::Empty(),
239 Symbols::Empty(), malformed_error_message);
240 UNREACHABLE(); 240 UNREACHABLE();
241 } 241 }
242 } 242 }
243 instance.SetTypeArguments(type_arguments); 243 instance.SetTypeArguments(type_arguments);
244 } 244 }
245 245
246 246
247 // Instantiate type arguments. 247 // Instantiate type arguments.
248 // Arg0: uninstantiated type arguments. 248 // Arg0: uninstantiated type arguments.
249 // Arg1: instantiator type arguments. 249 // Arg1: instantiator type arguments.
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 Bool::True() : Bool::False()); 581 Bool::True() : Bool::False());
582 if (FLAG_trace_type_checks) { 582 if (FLAG_trace_type_checks) {
583 PrintTypeCheck("InstanceOf", 583 PrintTypeCheck("InstanceOf",
584 instance, type, instantiator_type_arguments, result); 584 instance, type, instantiator_type_arguments, result);
585 } 585 }
586 if (!result.value() && !malformed_error.IsNull()) { 586 if (!result.value() && !malformed_error.IsNull()) {
587 // Throw a dynamic type error only if the instanceof test fails. 587 // Throw a dynamic type error only if the instanceof test fails.
588 const intptr_t location = GetCallerLocation(); 588 const intptr_t location = GetCallerLocation();
589 String& malformed_error_message = String::Handle( 589 String& malformed_error_message = String::Handle(
590 String::New(malformed_error.ToErrorCString())); 590 String::New(malformed_error.ToErrorCString()));
591 const String& no_name = String::Handle(Symbols::Empty());
592 Exceptions::CreateAndThrowTypeError( 591 Exceptions::CreateAndThrowTypeError(
593 location, no_name, no_name, no_name, malformed_error_message); 592 location, Symbols::Empty(), Symbols::Empty(),
593 Symbols::Empty(), malformed_error_message);
594 UNREACHABLE(); 594 UNREACHABLE();
595 } 595 }
596 UpdateTypeTestCache(instance, type, instantiator, 596 UpdateTypeTestCache(instance, type, instantiator,
597 instantiator_type_arguments, result, cache); 597 instantiator_type_arguments, result, cache);
598 arguments.SetReturn(result); 598 arguments.SetReturn(result);
599 } 599 }
600 600
601 601
602 // Check that the type of the given instance is a subtype of the given type and 602 // Check that the type of the given instance is a subtype of the given type and
603 // can therefore be assigned. 603 // can therefore be assigned.
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 ASSERT(arguments.ArgCount() == 700 ASSERT(arguments.ArgCount() ==
701 kConditionTypeErrorRuntimeEntry.argument_count()); 701 kConditionTypeErrorRuntimeEntry.argument_count());
702 const intptr_t location = GetCallerLocation(); 702 const intptr_t location = GetCallerLocation();
703 const Instance& src_instance = Instance::CheckedHandle(arguments.ArgAt(0)); 703 const Instance& src_instance = Instance::CheckedHandle(arguments.ArgAt(0));
704 ASSERT(src_instance.IsNull() || !src_instance.IsBool()); 704 ASSERT(src_instance.IsNull() || !src_instance.IsBool());
705 const Type& bool_interface = Type::Handle(Type::BoolType()); 705 const Type& bool_interface = Type::Handle(Type::BoolType());
706 const AbstractType& src_type = AbstractType::Handle(src_instance.GetType()); 706 const AbstractType& src_type = AbstractType::Handle(src_instance.GetType());
707 const String& src_type_name = String::Handle(src_type.UserVisibleName()); 707 const String& src_type_name = String::Handle(src_type.UserVisibleName());
708 const String& bool_type_name = 708 const String& bool_type_name =
709 String::Handle(bool_interface.UserVisibleName()); 709 String::Handle(bool_interface.UserVisibleName());
710 const String& expr = String::Handle(Symbols::New("boolean expression"));
711 const String& no_malformed_type_error = String::Handle(); 710 const String& no_malformed_type_error = String::Handle();
712 Exceptions::CreateAndThrowTypeError(location, src_type_name, bool_type_name, 711 Exceptions::CreateAndThrowTypeError(location, src_type_name, bool_type_name,
713 expr, no_malformed_type_error); 712 Symbols::BooleanExpression(),
713 no_malformed_type_error);
714 UNREACHABLE(); 714 UNREACHABLE();
715 } 715 }
716 716
717 717
718 // Report that the type of the type check is malformed. 718 // Report that the type of the type check is malformed.
719 // Arg0: src value. 719 // Arg0: src value.
720 // Arg1: name of instance being assigned to. 720 // Arg1: name of instance being assigned to.
721 // Arg2: malformed type error message. 721 // Arg2: malformed type error message.
722 // Return value: none, throws an exception. 722 // Return value: none, throws an exception.
723 DEFINE_RUNTIME_ENTRY(MalformedTypeError, 3) { 723 DEFINE_RUNTIME_ENTRY(MalformedTypeError, 3) {
724 ASSERT(arguments.ArgCount() == 724 ASSERT(arguments.ArgCount() ==
725 kMalformedTypeErrorRuntimeEntry.argument_count()); 725 kMalformedTypeErrorRuntimeEntry.argument_count());
726 const intptr_t location = GetCallerLocation(); 726 const intptr_t location = GetCallerLocation();
727 const Instance& src_value = Instance::CheckedHandle(arguments.ArgAt(0)); 727 const Instance& src_value = Instance::CheckedHandle(arguments.ArgAt(0));
728 const String& dst_name = String::CheckedHandle(arguments.ArgAt(1)); 728 const String& dst_name = String::CheckedHandle(arguments.ArgAt(1));
729 const String& malformed_error = String::CheckedHandle(arguments.ArgAt(2)); 729 const String& malformed_error = String::CheckedHandle(arguments.ArgAt(2));
730 const String& dst_type_name = String::Handle(Symbols::New("malformed"));
731 const AbstractType& src_type = AbstractType::Handle(src_value.GetType()); 730 const AbstractType& src_type = AbstractType::Handle(src_value.GetType());
732 const String& src_type_name = String::Handle(src_type.UserVisibleName()); 731 const String& src_type_name = String::Handle(src_type.UserVisibleName());
733 Exceptions::CreateAndThrowTypeError(location, src_type_name, 732 Exceptions::CreateAndThrowTypeError(location, src_type_name,
734 dst_type_name, dst_name, malformed_error); 733 Symbols::Malformed(),
734 dst_name, malformed_error);
735 UNREACHABLE(); 735 UNREACHABLE();
736 } 736 }
737 737
738 738
739 DEFINE_RUNTIME_ENTRY(Throw, 1) { 739 DEFINE_RUNTIME_ENTRY(Throw, 1) {
740 ASSERT(arguments.ArgCount() == kThrowRuntimeEntry.argument_count()); 740 ASSERT(arguments.ArgCount() == kThrowRuntimeEntry.argument_count());
741 const Instance& exception = Instance::CheckedHandle(arguments.ArgAt(0)); 741 const Instance& exception = Instance::CheckedHandle(arguments.ArgAt(0));
742 Exceptions::Throw(exception); 742 Exceptions::Throw(exception);
743 } 743 }
744 744
(...skipping 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after
1799 return; 1799 return;
1800 } 1800 }
1801 HeapTrace* heap_trace = Isolate::Current()->heap()->trace(); 1801 HeapTrace* heap_trace = Isolate::Current()->heap()->trace();
1802 heap_trace->TraceStoreIntoObject(RawObject::ToAddr(object), 1802 heap_trace->TraceStoreIntoObject(RawObject::ToAddr(object),
1803 field_addr, 1803 field_addr,
1804 RawObject::ToAddr(value)); 1804 RawObject::ToAddr(value));
1805 } 1805 }
1806 END_LEAF_RUNTIME_ENTRY 1806 END_LEAF_RUNTIME_ENTRY
1807 1807
1808 } // namespace dart 1808 } // namespace dart
OLDNEW
« no previous file with comments | « vm/class_finalizer.cc ('k') | vm/dart_api_impl.cc » ('j') | vm/symbols.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698