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

Side by Side Diff: src/ia32/full-codegen-ia32.cc

Issue 6240012: Optimize calls to object literal properties that are initialized with a funct... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: added x64 and arm code. Created 9 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1309 matching lines...) Expand 10 before | Expand all | Expand 10 after
1320 context()->Plug(eax); 1320 context()->Plug(eax);
1321 } 1321 }
1322 1322
1323 1323
1324 void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { 1324 void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
1325 Comment cmnt(masm_, "[ ObjectLiteral"); 1325 Comment cmnt(masm_, "[ ObjectLiteral");
1326 __ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); 1326 __ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
1327 __ push(FieldOperand(edi, JSFunction::kLiteralsOffset)); 1327 __ push(FieldOperand(edi, JSFunction::kLiteralsOffset));
1328 __ push(Immediate(Smi::FromInt(expr->literal_index()))); 1328 __ push(Immediate(Smi::FromInt(expr->literal_index())));
1329 __ push(Immediate(expr->constant_properties())); 1329 __ push(Immediate(expr->constant_properties()));
1330 __ push(Immediate(Smi::FromInt(expr->fast_elements() ? 1 : 0))); 1330 int flags = expr->fast_elements()
1331 ? ObjectLiteral::kFastElements
1332 : ObjectLiteral::kNoFlags;
1333 flags |= expr->has_function()
1334 ? ObjectLiteral::kHasFunction
1335 : ObjectLiteral::kNoFlags;
1336 __ push(Immediate(Smi::FromInt(flags)));
1331 if (expr->depth() > 1) { 1337 if (expr->depth() > 1) {
1332 __ CallRuntime(Runtime::kCreateObjectLiteral, 4); 1338 __ CallRuntime(Runtime::kCreateObjectLiteral, 4);
1333 } else { 1339 } else {
1334 __ CallRuntime(Runtime::kCreateObjectLiteralShallow, 4); 1340 __ CallRuntime(Runtime::kCreateObjectLiteralShallow, 4);
1335 } 1341 }
1336 1342
1337 // If result_saved is true the result is on top of the stack. If 1343 // If result_saved is true the result is on top of the stack. If
1338 // result_saved is false the result is in eax. 1344 // result_saved is false the result is in eax.
1339 bool result_saved = false; 1345 bool result_saved = false;
1340 1346
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1389 __ push(Immediate(property->kind() == ObjectLiteral::Property::SETTER ? 1395 __ push(Immediate(property->kind() == ObjectLiteral::Property::SETTER ?
1390 Smi::FromInt(1) : 1396 Smi::FromInt(1) :
1391 Smi::FromInt(0))); 1397 Smi::FromInt(0)));
1392 VisitForStackValue(value); 1398 VisitForStackValue(value);
1393 __ CallRuntime(Runtime::kDefineAccessor, 4); 1399 __ CallRuntime(Runtime::kDefineAccessor, 4);
1394 break; 1400 break;
1395 default: UNREACHABLE(); 1401 default: UNREACHABLE();
1396 } 1402 }
1397 } 1403 }
1398 1404
1405 if (expr->has_function()) {
1406 ASSERT(result_saved);
1407 __ push(Operand(esp, 0));
1408 __ CallRuntime(Runtime::kToFastProperties, 1);
1409 }
1410
1399 if (result_saved) { 1411 if (result_saved) {
1400 context()->PlugTOS(); 1412 context()->PlugTOS();
1401 } else { 1413 } else {
1402 context()->Plug(eax); 1414 context()->Plug(eax);
1403 } 1415 }
1404 } 1416 }
1405 1417
1406 1418
1407 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { 1419 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
1408 Comment cmnt(masm_, "[ ArrayLiteral"); 1420 Comment cmnt(masm_, "[ ArrayLiteral");
(...skipping 2957 matching lines...) Expand 10 before | Expand all | Expand 10 after
4366 // And return. 4378 // And return.
4367 __ ret(0); 4379 __ ret(0);
4368 } 4380 }
4369 4381
4370 4382
4371 #undef __ 4383 #undef __
4372 4384
4373 } } // namespace v8::internal 4385 } } // namespace v8::internal
4374 4386
4375 #endif // V8_TARGET_ARCH_IA32 4387 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698