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

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

Issue 1375443004: Allocate error messages in old space: needed for background compilation and rarely done (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Add comments Created 5 years, 2 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
« no previous file with comments | « no previous file | no next file » | 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) 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/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 5844 matching lines...) Expand 10 before | Expand all | Expand 10 after
5855 String* error_message) const { 5855 String* error_message) const {
5856 if (num_named_arguments > NumOptionalNamedParameters()) { 5856 if (num_named_arguments > NumOptionalNamedParameters()) {
5857 if (error_message != NULL) { 5857 if (error_message != NULL) {
5858 const intptr_t kMessageBufferSize = 64; 5858 const intptr_t kMessageBufferSize = 64;
5859 char message_buffer[kMessageBufferSize]; 5859 char message_buffer[kMessageBufferSize];
5860 OS::SNPrint(message_buffer, 5860 OS::SNPrint(message_buffer,
5861 kMessageBufferSize, 5861 kMessageBufferSize,
5862 "%" Pd " named passed, at most %" Pd " expected", 5862 "%" Pd " named passed, at most %" Pd " expected",
5863 num_named_arguments, 5863 num_named_arguments,
5864 NumOptionalNamedParameters()); 5864 NumOptionalNamedParameters());
5865 *error_message = String::New(message_buffer); 5865 // Allocate in old space because it can be invoked in background
5866 // optimizing compilation.
5867 *error_message = String::New(message_buffer, Heap::kOld);
5866 } 5868 }
5867 return false; // Too many named arguments. 5869 return false; // Too many named arguments.
5868 } 5870 }
5869 const intptr_t num_pos_args = num_arguments - num_named_arguments; 5871 const intptr_t num_pos_args = num_arguments - num_named_arguments;
5870 const intptr_t num_opt_pos_params = NumOptionalPositionalParameters(); 5872 const intptr_t num_opt_pos_params = NumOptionalPositionalParameters();
5871 const intptr_t num_pos_params = num_fixed_parameters() + num_opt_pos_params; 5873 const intptr_t num_pos_params = num_fixed_parameters() + num_opt_pos_params;
5872 if (num_pos_args > num_pos_params) { 5874 if (num_pos_args > num_pos_params) {
5873 if (error_message != NULL) { 5875 if (error_message != NULL) {
5874 const intptr_t kMessageBufferSize = 64; 5876 const intptr_t kMessageBufferSize = 64;
5875 char message_buffer[kMessageBufferSize]; 5877 char message_buffer[kMessageBufferSize];
5876 // Hide implicit parameters to the user. 5878 // Hide implicit parameters to the user.
5877 const intptr_t num_hidden_params = NumImplicitParameters(); 5879 const intptr_t num_hidden_params = NumImplicitParameters();
5878 OS::SNPrint(message_buffer, 5880 OS::SNPrint(message_buffer,
5879 kMessageBufferSize, 5881 kMessageBufferSize,
5880 "%" Pd "%s passed, %s%" Pd " expected", 5882 "%" Pd "%s passed, %s%" Pd " expected",
5881 num_pos_args - num_hidden_params, 5883 num_pos_args - num_hidden_params,
5882 num_opt_pos_params > 0 ? " positional" : "", 5884 num_opt_pos_params > 0 ? " positional" : "",
5883 num_opt_pos_params > 0 ? "at most " : "", 5885 num_opt_pos_params > 0 ? "at most " : "",
5884 num_pos_params - num_hidden_params); 5886 num_pos_params - num_hidden_params);
5885 *error_message = String::New(message_buffer); 5887 // Allocate in old space because it can be invoked in background
5888 // optimizing compilation.
5889 *error_message = String::New(message_buffer, Heap::kOld);
5886 } 5890 }
5887 return false; // Too many fixed and/or positional arguments. 5891 return false; // Too many fixed and/or positional arguments.
5888 } 5892 }
5889 if (num_pos_args < num_fixed_parameters()) { 5893 if (num_pos_args < num_fixed_parameters()) {
5890 if (error_message != NULL) { 5894 if (error_message != NULL) {
5891 const intptr_t kMessageBufferSize = 64; 5895 const intptr_t kMessageBufferSize = 64;
5892 char message_buffer[kMessageBufferSize]; 5896 char message_buffer[kMessageBufferSize];
5893 // Hide implicit parameters to the user. 5897 // Hide implicit parameters to the user.
5894 const intptr_t num_hidden_params = NumImplicitParameters(); 5898 const intptr_t num_hidden_params = NumImplicitParameters();
5895 OS::SNPrint(message_buffer, 5899 OS::SNPrint(message_buffer,
5896 kMessageBufferSize, 5900 kMessageBufferSize,
5897 "%" Pd "%s passed, %s%" Pd " expected", 5901 "%" Pd "%s passed, %s%" Pd " expected",
5898 num_pos_args - num_hidden_params, 5902 num_pos_args - num_hidden_params,
5899 num_opt_pos_params > 0 ? " positional" : "", 5903 num_opt_pos_params > 0 ? " positional" : "",
5900 num_opt_pos_params > 0 ? "at least " : "", 5904 num_opt_pos_params > 0 ? "at least " : "",
5901 num_fixed_parameters() - num_hidden_params); 5905 num_fixed_parameters() - num_hidden_params);
5902 *error_message = String::New(message_buffer); 5906 // Allocate in old space because it can be invoked in background
5907 // optimizing compilation.
5908 *error_message = String::New(message_buffer, Heap::kOld);
5903 } 5909 }
5904 return false; // Too few fixed and/or positional arguments. 5910 return false; // Too few fixed and/or positional arguments.
5905 } 5911 }
5906 return true; 5912 return true;
5907 } 5913 }
5908 5914
5909 5915
5910 bool Function::AreValidArguments(intptr_t num_arguments, 5916 bool Function::AreValidArguments(intptr_t num_arguments,
5911 const Array& argument_names, 5917 const Array& argument_names,
5912 String* error_message) const { 5918 String* error_message) const {
(...skipping 24 matching lines...) Expand all
5937 } 5943 }
5938 } 5944 }
5939 if (!found) { 5945 if (!found) {
5940 if (error_message != NULL) { 5946 if (error_message != NULL) {
5941 const intptr_t kMessageBufferSize = 64; 5947 const intptr_t kMessageBufferSize = 64;
5942 char message_buffer[kMessageBufferSize]; 5948 char message_buffer[kMessageBufferSize];
5943 OS::SNPrint(message_buffer, 5949 OS::SNPrint(message_buffer,
5944 kMessageBufferSize, 5950 kMessageBufferSize,
5945 "no optional formal parameter named '%s'", 5951 "no optional formal parameter named '%s'",
5946 argument_name.ToCString()); 5952 argument_name.ToCString());
5947 *error_message = String::New(message_buffer); 5953 // Allocate in old space because it can be invoked in background
5954 // optimizing compilation.
5955 *error_message = String::New(message_buffer, Heap::kOld);
5948 } 5956 }
5949 return false; 5957 return false;
5950 } 5958 }
5951 } 5959 }
5952 return true; 5960 return true;
5953 } 5961 }
5954 5962
5955 5963
5956 bool Function::AreValidArguments(const ArgumentsDescriptor& args_desc, 5964 bool Function::AreValidArguments(const ArgumentsDescriptor& args_desc,
5957 String* error_message) const { 5965 String* error_message) const {
(...skipping 25 matching lines...) Expand all
5983 } 5991 }
5984 } 5992 }
5985 if (!found) { 5993 if (!found) {
5986 if (error_message != NULL) { 5994 if (error_message != NULL) {
5987 const intptr_t kMessageBufferSize = 64; 5995 const intptr_t kMessageBufferSize = 64;
5988 char message_buffer[kMessageBufferSize]; 5996 char message_buffer[kMessageBufferSize];
5989 OS::SNPrint(message_buffer, 5997 OS::SNPrint(message_buffer,
5990 kMessageBufferSize, 5998 kMessageBufferSize,
5991 "no optional formal parameter named '%s'", 5999 "no optional formal parameter named '%s'",
5992 argument_name.ToCString()); 6000 argument_name.ToCString());
5993 *error_message = String::New(message_buffer); 6001 // Allocate in old space because it can be invoked in background
6002 // optimizing compilation.
6003 *error_message = String::New(message_buffer, Heap::kOld);
5994 } 6004 }
5995 return false; 6005 return false;
5996 } 6006 }
5997 } 6007 }
5998 return true; 6008 return true;
5999 } 6009 }
6000 6010
6001 6011
6002 // Helper allocating a C string buffer in the zone, printing the fully qualified 6012 // Helper allocating a C string buffer in the zone, printing the fully qualified
6003 // name of a function in it, and replacing ':' by '_' to make sure the 6013 // name of a function in it, and replacing ':' by '_' to make sure the
(...skipping 8519 matching lines...) Expand 10 before | Expand all | Expand 10 after
14523 Error* bound_error) const { 14533 Error* bound_error) const {
14524 ASSERT(other.IsFinalized()); 14534 ASSERT(other.IsFinalized());
14525 ASSERT(!other.IsDynamicType()); 14535 ASSERT(!other.IsDynamicType());
14526 ASSERT(!other.IsMalformed()); 14536 ASSERT(!other.IsMalformed());
14527 ASSERT(!other.IsMalbounded()); 14537 ASSERT(!other.IsMalbounded());
14528 if (other.IsVoidType()) { 14538 if (other.IsVoidType()) {
14529 return false; 14539 return false;
14530 } 14540 }
14531 Isolate* isolate = Isolate::Current(); 14541 Isolate* isolate = Isolate::Current();
14532 const Class& cls = Class::Handle(isolate, clazz()); 14542 const Class& cls = Class::Handle(isolate, clazz());
14533 TypeArguments& type_arguments = 14543 TypeArguments& type_arguments = TypeArguments::Handle(isolate);
14534 TypeArguments::Handle(isolate);
14535 if (cls.NumTypeArguments() > 0) { 14544 if (cls.NumTypeArguments() > 0) {
14536 type_arguments = GetTypeArguments(); 14545 type_arguments = GetTypeArguments();
14537 ASSERT(type_arguments.IsNull() || type_arguments.IsCanonical()); 14546 ASSERT(type_arguments.IsNull() || type_arguments.IsCanonical());
14538 // The number of type arguments in the instance must be greater or equal to 14547 // The number of type arguments in the instance must be greater or equal to
14539 // the number of type arguments expected by the instance class. 14548 // the number of type arguments expected by the instance class.
14540 // A discrepancy is allowed for closures, which borrow the type argument 14549 // A discrepancy is allowed for closures, which borrow the type argument
14541 // vector of their instantiator, which may be of a subclass of the class 14550 // vector of their instantiator, which may be of a subclass of the class
14542 // defining the closure. Truncating the vector to the correct length on 14551 // defining the closure. Truncating the vector to the correct length on
14543 // instantiation is unnecessary. The vector may therefore be longer. 14552 // instantiation is unnecessary. The vector may therefore be longer.
14544 // Also, an optimization reuses the type argument vector of the instantiator 14553 // Also, an optimization reuses the type argument vector of the instantiator
(...skipping 6937 matching lines...) Expand 10 before | Expand all | Expand 10 after
21482 return tag_label.ToCString(); 21491 return tag_label.ToCString();
21483 } 21492 }
21484 21493
21485 21494
21486 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 21495 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
21487 Instance::PrintJSONImpl(stream, ref); 21496 Instance::PrintJSONImpl(stream, ref);
21488 } 21497 }
21489 21498
21490 21499
21491 } // namespace dart 21500 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698