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

Unified Diff: src/hydrogen.cc

Issue 756423006: Optimize GetPrototype (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add test and add back Push/Pop Created 6 years 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 | « src/array.js ('k') | src/hydrogen-instructions.h » ('j') | 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 8570b33ce08a509bc08b5b03250327f116080d87..8df8f6ed43879298a9e19791a50a9e6297ec4132 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -12390,6 +12390,54 @@ void HOptimizedGraphBuilder::GenerateDebugIsActive(CallRuntime* call) {
}
+void HOptimizedGraphBuilder::GenerateGetPrototype(CallRuntime* call) {
+ DCHECK(call->arguments()->length() == 1);
+ CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
+ HValue* object = Pop();
+
+ NoObservableSideEffectsScope no_effects(this);
+
+ HValue* map = Add<HLoadNamedField>(object, static_cast<HValue*>(NULL),
+ HObjectAccess::ForMap());
+ HValue* bit_field = Add<HLoadNamedField>(map, static_cast<HValue*>(NULL),
+ HObjectAccess::ForMapBitField());
+ HValue* is_access_check_needed_mask =
+ Add<HConstant>(1 << Map::kIsAccessCheckNeeded);
+ HValue* is_access_check_needed_test = AddUncasted<HBitwise>(
+ Token::BIT_AND, bit_field, is_access_check_needed_mask);
+
+ HValue* proto = Add<HLoadNamedField>(map, static_cast<HValue*>(NULL),
+ HObjectAccess::ForPrototype());
+ HValue* proto_map = Add<HLoadNamedField>(proto, static_cast<HValue*>(NULL),
+ HObjectAccess::ForMap());
+ HValue* proto_bit_field = Add<HLoadNamedField>(
+ proto_map, static_cast<HValue*>(NULL), HObjectAccess::ForMapBitField());
+ HValue* is_hidden_prototype_mask =
+ Add<HConstant>(1 << Map::kIsHiddenPrototype);
+ HValue* is_hidden_prototype_test = AddUncasted<HBitwise>(
+ Token::BIT_AND, proto_bit_field, is_hidden_prototype_mask);
+
+ {
+ IfBuilder needs_runtime(this);
+ needs_runtime.If<HCompareNumericAndBranch>(
+ is_access_check_needed_test, graph()->GetConstant0(), Token::NE);
+ needs_runtime.OrIf<HCompareNumericAndBranch>(
+ is_hidden_prototype_test, graph()->GetConstant0(), Token::NE);
+
+ needs_runtime.Then();
+ {
+ Add<HPushArguments>(object);
+ Push(Add<HCallRuntime>(
+ call->name(), Runtime::FunctionForId(Runtime::kGetPrototype), 1));
+ }
+
+ needs_runtime.Else();
+ Push(proto);
+ }
+ return ast_context()->ReturnValue(Pop());
+}
+
+
#undef CHECK_BAILOUT
#undef CHECK_ALIVE
« no previous file with comments | « src/array.js ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698