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

Unified Diff: runtime/vm/ast.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/lib/integers.cc ('k') | runtime/vm/intermediate_language.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/ast.cc
diff --git a/runtime/vm/ast.cc b/runtime/vm/ast.cc
index 26618b51f23308e76dfb7051f3f86006c1836b62..48bd0534e0b425094f3e700caaeeb38ae81486c7 100644
--- a/runtime/vm/ast.cc
+++ b/runtime/vm/ast.cc
@@ -572,9 +572,11 @@ AstNode* StaticGetterNode::MakeAssignmentNode(AstNode* rhs) {
if (is_super_getter()) {
ASSERT(receiver() != NULL);
const String& setter_name =
- String::ZoneHandle(zone, Field::SetterSymbol(field_name_));
- Function& setter = Function::ZoneHandle(zone,
- Resolver::ResolveDynamicAnyArgs(cls(), setter_name));
+ String::ZoneHandle(zone, Field::LookupSetterSymbol(field_name_));
+ Function& setter = Function::ZoneHandle(zone);
+ if (!setter_name.IsNull()) {
+ setter = Resolver::ResolveDynamicAnyArgs(cls(), setter_name);
+ }
if (setter.IsNull() || setter.is_abstract()) {
// No instance setter found in super class chain,
// noSuchMethod will be called at runtime.
@@ -618,15 +620,17 @@ AstNode* StaticGetterNode::MakeAssignmentNode(AstNode* rhs) {
}
// No field found in prefix. Look for a setter function.
- const String& setter_name = String::Handle(zone,
- Field::SetterName(field_name_));
- obj = prefix.LookupObject(setter_name);
- if (obj.IsFunction()) {
- const Function& setter = Function::ZoneHandle(zone,
- Function::Cast(obj).raw());
- ASSERT(setter.is_static() && setter.IsSetterFunction());
- return new StaticSetterNode(
- token_pos(), NULL, field_name_, setter, rhs);
+ const String& setter_name =
+ String::Handle(zone, Field::LookupSetterSymbol(field_name_));
+ if (!setter_name.IsNull()) {
+ obj = prefix.LookupObject(setter_name);
+ if (obj.IsFunction()) {
+ const Function& setter =
+ Function::ZoneHandle(zone, Function::Cast(obj).raw());
+ ASSERT(setter.is_static() && setter.IsSetterFunction());
+ return new StaticSetterNode(
+ token_pos(), NULL, field_name_, setter, rhs);
+ }
}
// No writeable field and no setter found in the prefix. Return a
@@ -651,14 +655,17 @@ AstNode* StaticGetterNode::MakeAssignmentNode(AstNode* rhs) {
}
// No field found in library. Look for a setter function.
- const String& setter_name = String::Handle(zone,
- Field::SetterName(field_name_));
- obj = library.ResolveName(setter_name);
- if (obj.IsFunction()) {
- const Function& setter = Function::ZoneHandle(zone,
- Function::Cast(obj).raw());
- ASSERT(setter.is_static() && setter.IsSetterFunction());
- return new StaticSetterNode(token_pos(), NULL, field_name_, setter, rhs);
+ const String& setter_name =
+ String::Handle(zone, Field::LookupSetterSymbol(field_name_));
+ if (!setter_name.IsNull()) {
+ obj = library.ResolveName(setter_name);
+ if (obj.IsFunction()) {
+ const Function& setter =
+ Function::ZoneHandle(zone, Function::Cast(obj).raw());
+ ASSERT(setter.is_static() && setter.IsSetterFunction());
+ return
+ new StaticSetterNode(token_pos(), NULL, field_name_, setter, rhs);
+ }
}
// No writeable field and no setter found in the library. Return a
@@ -685,8 +692,9 @@ AstNode* StaticGetterNode::MakeAssignmentNode(AstNode* rhs) {
return new StaticSetterNode(token_pos(), NULL, cls(), field_name_, rhs);
}
#if defined(DEBUG)
- const String& getter_name = String::Handle(zone,
- Field::GetterName(field_name_));
+ const String& getter_name =
+ String::Handle(zone, Field::LookupGetterSymbol(field_name_));
+ ASSERT(!getter_name.IsNull());
const Function& getter =
Function::Handle(zone, cls().LookupStaticFunction(getter_name));
ASSERT(!getter.IsNull() &&
@@ -741,7 +749,10 @@ const Instance* StaticGetterNode::EvalConstExpr() const {
return NULL;
}
const String& getter_name =
- String::Handle(Field::GetterName(this->field_name()));
+ String::Handle(Field::LookupGetterSymbol(this->field_name()));
+ if (getter_name.IsNull()) {
+ return NULL;
+ }
const Function& getter_func =
Function::Handle(this->cls().LookupStaticFunction(getter_name));
if (getter_func.IsNull() || !getter_func.is_const()) {
« no previous file with comments | « runtime/lib/integers.cc ('k') | runtime/vm/intermediate_language.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698