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 |