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

Unified Diff: runtime/vm/object.cc

Issue 1320673012: Lookup getter/setter symbols before alllocating them, thus eliminating extra String allocations in … (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Formatting Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/object_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index 86d461ac28b466c3ba800752a4cfa955947de53c..f3400162d8a368d882430ff6daad1cc22cac9fdb 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -2120,7 +2120,8 @@ void Class::SetFunctions(const Array& value) const {
void Class::AddFunction(const Function& function) const {
const Array& arr = Array::Handle(functions());
- const Array& new_arr = Array::Handle(Array::Grow(arr, arr.Length() + 1));
+ const Array& new_arr =
+ Array::Handle(Array::Grow(arr, arr.Length() + 1, Heap::kOld));
new_arr.SetAt(arr.Length(), function);
StorePointer(&raw_ptr()->functions_, new_arr.raw());
// Add to hash table, if any.
@@ -7182,7 +7183,7 @@ void RedirectionData::PrintJSONImpl(JSONStream* stream, bool ref) const {
RawString* Field::GetterName(const String& field_name) {
- return Field::GetterSymbol(field_name);
+ return String::Concat(Symbols::GetterPrefix(), field_name);
}
@@ -7191,6 +7192,11 @@ RawString* Field::GetterSymbol(const String& field_name) {
}
+RawString* Field::LookupGetterSymbol(const String& field_name) {
+ return Symbols::LookupFromConcat(Symbols::GetterPrefix(), field_name);
+}
+
+
RawString* Field::SetterName(const String& field_name) {
return String::Concat(Symbols::SetterPrefix(), field_name);
}
@@ -7201,6 +7207,11 @@ RawString* Field::SetterSymbol(const String& field_name) {
}
+RawString* Field::LookupSetterSymbol(const String& field_name) {
+ return Symbols::LookupFromConcat(Symbols::SetterPrefix(), field_name);
+}
+
+
RawString* Field::NameFromGetter(const String& getter_name) {
return Symbols::New(getter_name, kGetterPrefixLength,
getter_name.Length() - kGetterPrefixLength);
@@ -10709,9 +10720,16 @@ RawObject* Namespace::Lookup(const String& name) const {
if (!Field::IsGetterName(name) &&
!Field::IsSetterName(name) &&
(obj.IsNull() || obj.IsLibraryPrefix())) {
- obj = lib.LookupEntry(String::Handle(Field::GetterName(name)), &ignore);
+ const String& getter_name = String::Handle(Field::LookupGetterSymbol(name));
+ if (!getter_name.IsNull()) {
+ obj = lib.LookupEntry(getter_name, &ignore);
+ }
if (obj.IsNull()) {
- obj = lib.LookupEntry(String::Handle(Field::SetterName(name)), &ignore);
+ const String& setter_name =
+ String::Handle(Field::LookupSetterSymbol(name));
+ if (!setter_name.IsNull()) {
+ obj = lib.LookupEntry(setter_name, &ignore);
+ }
}
}
@@ -16973,7 +16991,8 @@ static bool Are64bitOperands(const Integer& op1, const Integer& op2) {
}
-RawInteger* Integer::BitOp(Token::Kind kind, const Integer& other) const {
+RawInteger* Integer::BitOp(
+ Token::Kind kind, const Integer& other, Heap::Space space) const {
if (IsSmi() && other.IsSmi()) {
intptr_t op1_value = Smi::Value(Smi::RawCast(raw()));
intptr_t op2_value = Smi::Value(Smi::RawCast(other.raw()));
@@ -16998,11 +17017,11 @@ RawInteger* Integer::BitOp(Token::Kind kind, const Integer& other) const {
int64_t b = other.AsInt64Value();
switch (kind) {
case Token::kBIT_AND:
- return Integer::New(a & b);
+ return Integer::New(a & b, space);
case Token::kBIT_OR:
- return Integer::New(a | b);
+ return Integer::New(a | b, space);
case Token::kBIT_XOR:
- return Integer::New(a ^ b);
+ return Integer::New(a ^ b, space);
default:
UNIMPLEMENTED();
}
@@ -17014,6 +17033,7 @@ RawInteger* Integer::BitOp(Token::Kind kind, const Integer& other) const {
// TODO(srdjan): Clarify handling of negative right operand in a shift op.
RawInteger* Smi::ShiftOp(Token::Kind kind,
const Smi& other,
+ Heap::Space space,
const bool silent) const {
intptr_t result = 0;
const intptr_t left_value = Value();
@@ -17028,10 +17048,10 @@ RawInteger* Smi::ShiftOp(Token::Kind kind,
int cnt = Utils::BitLength(left_value);
if ((cnt + right_value) > Smi::kBits) {
if ((cnt + right_value) > Mint::kBits) {
- return Bigint::NewFromShiftedInt64(left_value, right_value);
+ return Bigint::NewFromShiftedInt64(left_value, right_value, space);
} else {
int64_t left_64 = left_value;
- return Integer::New(left_64 << right_value, Heap::kNew, silent);
+ return Integer::New(left_64 << right_value, space, silent);
}
}
}
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/object_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698