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

Unified Diff: src/hydrogen.cc

Issue 10615002: Track allocation info (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Diff with b_e Created 8 years, 2 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 | « src/heap.cc ('k') | src/ia32/builtins-ia32.cc » ('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 374e54c97389e448721421ca80898aeb6d42df1d..10623fb59db1ef8268f0c662a551f296b64bfefd 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -7747,6 +7747,10 @@ static bool IsAllocationInlineable(Handle<JSFunction> constructor) {
constructor->initial_map()->instance_size() < HAllocateObject::kMaxSize;
}
+static bool IsArrayConstructInlinable(Handle<JSFunction> constructor) {
+ return constructor->GetIsolate()->global_context()->array_function() ==
+ *constructor;
+}
void HGraphBuilder::VisitCallNew(CallNew* expr) {
ASSERT(!HasStackOverflow());
@@ -7795,6 +7799,30 @@ void HGraphBuilder::VisitCallNew(CallNew* expr) {
new(zone()) HCallNew(context, function, argument_count));
call->set_position(expr->position());
return ast_context()->ReturnInstruction(call, expr->id());
+ } else if (expr->IsMonomorphic() &&
+ argument_count == 1 &&
+ IsArrayConstructInlinable(expr->target())) {
+ CHECK_ALIVE(VisitForValue(expr->expression()));
+ HValue* function = Top();
+ environment()->Drop(1);
+ Handle<JSFunction> constructor = expr->target();
+ ElementsKind elements_kind = expr->elements_kind();
+ AddInstruction(new(zone()) HCheckFunction(function, constructor));
+ Factory* f = graph()->isolate()->factory();
+ Handle<JSArray> boilerplate = f->NewEmptyJSArray(elements_kind, TENURED);
+ HValue* context = environment()->LookupContext();
+ int total_size = JSArray::kSize + FixedArray::kHeaderSize;
+ if (IsFastDoubleElementsKind(elements_kind)) {
+ total_size += boilerplate->elements()->length() * kDoubleSize;
+ } else {
+ total_size += boilerplate->elements()->length() * kPointerSize;
+ }
+ HFastLiteral* empty_array = new(zone()) HFastLiteral(context,
+ boilerplate,
+ total_size,
+ 0,
+ 0);
+ return ast_context()->ReturnInstruction(empty_array, expr->id());
} else {
// The constructor function is both an operand to the instruction and an
// argument to the construct call.
« no previous file with comments | « src/heap.cc ('k') | src/ia32/builtins-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698