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

Side by Side Diff: src/factory.cc

Issue 10649008: Fix sharing of literal boilerplates for optimized code. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 6 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
« no previous file with comments | « src/compiler.cc ('k') | src/flag-definitions.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 ? isolate()->function_map() 548 ? isolate()->function_map()
549 : isolate()->strict_mode_function_map(), 549 : isolate()->strict_mode_function_map(),
550 pretenure); 550 pretenure);
551 551
552 if (function_info->ic_age() != isolate()->heap()->global_ic_age()) { 552 if (function_info->ic_age() != isolate()->heap()->global_ic_age()) {
553 function_info->ResetForNewContext(isolate()->heap()->global_ic_age()); 553 function_info->ResetForNewContext(isolate()->heap()->global_ic_age());
554 } 554 }
555 555
556 result->set_context(*context); 556 result->set_context(*context);
557 557
558 int index = FLAG_cache_optimized_code 558 int index = function_info->SearchOptimizedCodeMap(context->global_context());
559 ? function_info->SearchOptimizedCodeMap(context->global_context()) 559 if (!function_info->bound() && index < 0) {
560 : -1; 560 int number_of_literals = function_info->num_literals();
561 if (!function_info->bound()) { 561 Handle<FixedArray> literals = NewFixedArray(number_of_literals, pretenure);
562 if (index > 0) { 562 if (number_of_literals > 0) {
563 FixedArray* code_map = 563 // Store the global context in the literals array prefix. This
564 FixedArray::cast(function_info->optimized_code_map()); 564 // context will be used when creating object, regexp and array
565 FixedArray* cached_literals = FixedArray::cast(code_map->get(index + 1)); 565 // literals in this function.
566 ASSERT(cached_literals != NULL); 566 literals->set(JSFunction::kLiteralGlobalContextIndex,
567 ASSERT(function_info->num_literals() == 0 || 567 context->global_context());
568 (code_map->get(index - 1) ==
569 cached_literals->get(JSFunction::kLiteralGlobalContextIndex)));
570 result->set_literals(cached_literals);
571 } else {
572 int number_of_literals = function_info->num_literals();
573 Handle<FixedArray> literals =
574 NewFixedArray(number_of_literals, pretenure);
575 if (number_of_literals > 0) {
576 // Store the object, regexp and array functions in the literals
577 // array prefix. These functions will be used when creating
578 // object, regexp and array literals in this function.
579 literals->set(JSFunction::kLiteralGlobalContextIndex,
580 context->global_context());
581 }
582 result->set_literals(*literals);
583 } 568 }
569 result->set_literals(*literals);
584 } 570 }
585 571
586 if (index > 0) { 572 if (index > 0) {
587 // Caching of optimized code enabled and optimized code found. 573 // Caching of optimized code enabled and optimized code found.
588 Code* code = Code::cast( 574 function_info->InstallFromOptimizedCodeMap(*result, index);
589 FixedArray::cast(function_info->optimized_code_map())->get(index));
590 ASSERT(code != NULL);
591 result->ReplaceCode(code);
592 return result; 575 return result;
593 } 576 }
594 577
595 if (V8::UseCrankshaft() && 578 if (V8::UseCrankshaft() &&
596 FLAG_always_opt && 579 FLAG_always_opt &&
597 result->is_compiled() && 580 result->is_compiled() &&
598 !function_info->is_toplevel() && 581 !function_info->is_toplevel() &&
599 function_info->allows_lazy_compilation() && 582 function_info->allows_lazy_compilation() &&
600 !function_info->optimization_disabled()) { 583 !function_info->optimization_disabled()) {
601 result->MarkForLazyRecompilation(); 584 result->MarkForLazyRecompilation();
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after
1509 1492
1510 1493
1511 Handle<Object> Factory::ToBoolean(bool value) { 1494 Handle<Object> Factory::ToBoolean(bool value) {
1512 return Handle<Object>(value 1495 return Handle<Object>(value
1513 ? isolate()->heap()->true_value() 1496 ? isolate()->heap()->true_value()
1514 : isolate()->heap()->false_value()); 1497 : isolate()->heap()->false_value());
1515 } 1498 }
1516 1499
1517 1500
1518 } } // namespace v8::internal 1501 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/compiler.cc ('k') | src/flag-definitions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698