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

Side by Side Diff: vm/code_generator.cc

Issue 8363034: Report NullPointerException when we try to construct a regular expression (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: '' Created 9 years, 1 month 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 | « vm/ast.h ('k') | vm/parser.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/code_generator.h" 5 #include "vm/code_generator.h"
6 6
7 #include "vm/code_index_table.h" 7 #include "vm/code_index_table.h"
8 #include "vm/code_patcher.h" 8 #include "vm/code_patcher.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/dart_api_impl.h" 10 #include "vm/dart_api_impl.h"
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 } 601 }
602 if (!result.IsSmi()) { 602 if (!result.IsSmi()) {
603 const Class& cls = Class::Handle(result.clazz()); 603 const Class& cls = Class::Handle(result.clazz());
604 ASSERT(!cls.IsNull()); 604 ASSERT(!cls.IsNull());
605 function = cls.signature_function(); 605 function = cls.signature_function();
606 if (!function.IsNull()) { 606 if (!function.IsNull()) {
607 arguments.SetReturn(result); 607 arguments.SetReturn(result);
608 return; // Return closure object. 608 return; // Return closure object.
609 } 609 }
610 } 610 }
611 Exceptions::ThrowByType(Exceptions::kObjectNotClosure, invoke_arguments); 611 Exceptions::ThrowByType(
612 result.IsNull() ? Exceptions::kNullPointer :
613 Exceptions::kObjectNotClosure,
614 invoke_arguments);
612 } 615 }
613 616
614 617
615 // Invoke Implicit Closure function. 618 // Invoke Implicit Closure function.
616 // Arg0: closure object. 619 // Arg0: closure object.
617 // Arg1: arguments descriptor (originally passed as dart instance invocation). 620 // Arg1: arguments descriptor (originally passed as dart instance invocation).
618 // Arg2: arguments array (originally passed to dart instance invocation). 621 // Arg2: arguments array (originally passed to dart instance invocation).
619 DEFINE_RUNTIME_ENTRY(InvokeImplicitClosureFunction, 3) { 622 DEFINE_RUNTIME_ENTRY(InvokeImplicitClosureFunction, 3) {
620 ASSERT(arguments.Count() == 623 ASSERT(arguments.Count() ==
621 kInvokeImplicitClosureFunctionRuntimeEntry.argument_count()); 624 kInvokeImplicitClosureFunctionRuntimeEntry.argument_count());
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 } 728 }
726 729
727 730
728 // Report that an object is not a closure. 731 // Report that an object is not a closure.
729 // Arg0: non-closure object. 732 // Arg0: non-closure object.
730 // Arg1: arguments array. 733 // Arg1: arguments array.
731 DEFINE_RUNTIME_ENTRY(ReportObjectNotClosure, 2) { 734 DEFINE_RUNTIME_ENTRY(ReportObjectNotClosure, 2) {
732 ASSERT(arguments.Count() == 735 ASSERT(arguments.Count() ==
733 kReportObjectNotClosureRuntimeEntry.argument_count()); 736 kReportObjectNotClosureRuntimeEntry.argument_count());
734 const Instance& bad_closure = Instance::CheckedHandle(arguments.At(0)); 737 const Instance& bad_closure = Instance::CheckedHandle(arguments.At(0));
738 if (bad_closure.IsNull()) {
739 GrowableArray<const Object*> args;
740 Exceptions::ThrowByType(Exceptions::kNullPointer, args);
741 }
735 // const Array& arguments = Array::CheckedHandle(arguments.At(1)); 742 // const Array& arguments = Array::CheckedHandle(arguments.At(1));
736 OS::PrintErr("object '%s' is not a closure\n", bad_closure.ToCString()); 743 OS::PrintErr("object '%s' is not a closure\n", bad_closure.ToCString());
737 GrowableArray<const Object*> args; 744 GrowableArray<const Object*> args;
738 Exceptions::ThrowByType(Exceptions::kObjectNotClosure, args); 745 Exceptions::ThrowByType(Exceptions::kObjectNotClosure, args);
739 } 746 }
740 747
741 748
742 DEFINE_RUNTIME_ENTRY(ClosureArgumentMismatch, 0) { 749 DEFINE_RUNTIME_ENTRY(ClosureArgumentMismatch, 0) {
743 ASSERT(arguments.Count() == 750 ASSERT(arguments.Count() ==
744 kClosureArgumentMismatchRuntimeEntry.argument_count()); 751 kClosureArgumentMismatchRuntimeEntry.argument_count());
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 } 962 }
956 } 963 }
957 } 964 }
958 // The cache is null terminated, therefore the loop above should never 965 // The cache is null terminated, therefore the loop above should never
959 // terminate by itself. 966 // terminate by itself.
960 UNREACHABLE(); 967 UNREACHABLE();
961 return Code::null(); 968 return Code::null();
962 } 969 }
963 970
964 } // namespace dart 971 } // namespace dart
OLDNEW
« no previous file with comments | « vm/ast.h ('k') | vm/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698