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

Unified Diff: src/hydrogen.cc

Issue 220163012: Inline loading of immutable properties (Closed) Base URL: https://github.com/v8/v8.git@master
Patch Set: Created 6 years, 9 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index 6587ce97199ca944f8daaa8938bcbf73b23f6414..36ceb32b43c0b09cafc5708f1f88ba60417b8d4a 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -6716,6 +6716,31 @@ void HOptimizedGraphBuilder::BuildLoad(Property* expr,
Handle<String> name = expr->key()->AsLiteral()->AsPropertyName();
HValue* object = Pop();
+ // See if the property to be loaded is non-configurable and non-writable
+ if (object->IsConstant() &&
+ HConstant::cast(object)->handle(isolate())->IsJSObject()) {
+ Handle<JSObject> js_object =
+ Handle<JSObject>::cast(HConstant::cast(object)->handle(isolate()));
+
+ if (!js_object->map()->is_observed()) {
+ LookupResult lookup(isolate());
+ js_object->LocalLookup(*name, &lookup, false);
+
+ if (lookup.IsFound() && lookup.IsCacheable() &&
+ (js_object->map()->is_frozen() ||
Toon Verwaest 2014/04/02 14:51:47 You don't need to special-case is_frozen(), such p
+ (lookup.IsReadOnly() && lookup.IsDontDelete()))) {
+ Handle<Object> value = handle(lookup.GetLazyValue(), isolate());
+
+ if (!value.is_null() &&
+ !value->IsTheHole() &&
+ !value->IsCallable()) {
Toon Verwaest 2014/04/02 14:51:47 Why these cases? Can you introduce abstractions th
p.antonov 2014/04/02 15:53:58 The null check should actually be unnecessary (sin
+ instr = New<HConstant>(value);
+ return ast_context()->ReturnInstruction(instr, ast_id);
+ }
+ }
+ }
+ }
+
instr = BuildNamedAccess(LOAD, ast_id, expr->LoadId(), expr,
object, name, NULL, expr->IsUninitialized());
if (instr == NULL) return;
« 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