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

Side by Side Diff: src/factory.cc

Issue 10103035: Share optimized code for closures. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: added x64 and ARM ports Created 8 years, 7 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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 ? isolate()->function_map() 544 ? isolate()->function_map()
545 : isolate()->strict_mode_function_map(), 545 : isolate()->strict_mode_function_map(),
546 pretenure); 546 pretenure);
547 547
548 if (function_info->ic_age() != isolate()->heap()->global_ic_age()) { 548 if (function_info->ic_age() != isolate()->heap()->global_ic_age()) {
549 function_info->ResetForNewContext(isolate()->heap()->global_ic_age()); 549 function_info->ResetForNewContext(isolate()->heap()->global_ic_age());
550 } 550 }
551 551
552 result->set_context(*context); 552 result->set_context(*context);
553 if (!function_info->bound()) { 553 if (!function_info->bound()) {
554 int number_of_literals = function_info->num_literals(); 554 int index = FLAG_cache_optimized_code
555 Handle<FixedArray> literals = NewFixedArray(number_of_literals, pretenure); 555 ? function_info->SearchOptimizedCodeMap(context->global_context())
556 if (number_of_literals > 0) { 556 : -1;
557 // Store the object, regexp and array functions in the literals 557 if (index > 0) {
558 // array prefix. These functions will be used when creating 558 FixedArray* code_map =
559 // object, regexp and array literals in this function. 559 FixedArray::cast(function_info->optimized_code_map());
560 literals->set(JSFunction::kLiteralGlobalContextIndex, 560 FixedArray* cached_literals =
561 context->global_context()); 561 FixedArray::cast(code_map->get(index + 1));
Michael Starzinger 2012/05/23 11:16:29 It would be nice to have constants for these offse
fschneider 2012/06/14 11:08:23 Agree. Though I'd have the constants relative to t
562 ASSERT(cached_literals != NULL);
Michael Starzinger 2012/05/23 11:16:29 Better add an ASSERT that the global context store
fschneider 2012/06/14 11:08:23 Done.
563 result->set_literals(cached_literals);
564 } else {
565 int number_of_literals = function_info->num_literals();
566 Handle<FixedArray> literals =
567 NewFixedArray(number_of_literals, pretenure);
568 if (number_of_literals > 0) {
569 // Store the object, regexp and array functions in the literals
570 // array prefix. These functions will be used when creating
571 // object, regexp and array literals in this function.
572 literals->set(JSFunction::kLiteralGlobalContextIndex,
573 context->global_context());
574 }
575 result->set_literals(*literals);
562 } 576 }
563 result->set_literals(*literals);
564 } 577 }
578
579 if (FLAG_cache_optimized_code) {
580 int index =
581 function_info->SearchOptimizedCodeMap(context->global_context());
582 if (index > 0) {
583 Code* code = Code::cast(
584 FixedArray::cast(function_info->optimized_code_map())->get(index));
585 ASSERT(code != NULL);
586 result->ReplaceCode(code);
587 return result;
588 }
589 }
590
565 if (V8::UseCrankshaft() && 591 if (V8::UseCrankshaft() &&
566 FLAG_always_opt && 592 FLAG_always_opt &&
567 result->is_compiled() && 593 result->is_compiled() &&
568 !function_info->is_toplevel() && 594 !function_info->is_toplevel() &&
569 function_info->allows_lazy_compilation() && 595 function_info->allows_lazy_compilation() &&
570 !function_info->optimization_disabled()) { 596 !function_info->optimization_disabled()) {
571 result->MarkForLazyRecompilation(); 597 result->MarkForLazyRecompilation();
572 } 598 }
573 return result; 599 return result;
574 } 600 }
(...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after
1440 1466
1441 1467
1442 Handle<Object> Factory::ToBoolean(bool value) { 1468 Handle<Object> Factory::ToBoolean(bool value) {
1443 return Handle<Object>(value 1469 return Handle<Object>(value
1444 ? isolate()->heap()->true_value() 1470 ? isolate()->heap()->true_value()
1445 : isolate()->heap()->false_value()); 1471 : isolate()->heap()->false_value());
1446 } 1472 }
1447 1473
1448 1474
1449 } } // namespace v8::internal 1475 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698