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

Unified Diff: src/objects.cc

Issue 873233002: Cache WeakCell for optimized code. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add check Created 5 years, 11 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/objects.h ('k') | src/x64/lithium-codegen-x64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 9ec776ddafdbe4b463ce158307192bbd97948479..0c61001936bfd0cd39b06ac44dadc20176eeb771 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -11033,6 +11033,29 @@ const char* Code::Kind2String(Kind kind) {
}
+Handle<WeakCell> Code::WeakCellFor(Handle<Code> code) {
+ DCHECK(code->kind() == OPTIMIZED_FUNCTION);
+ WeakCell* raw_cell = code->CachedWeakCell();
+ if (raw_cell != NULL) return Handle<WeakCell>(raw_cell);
+ Handle<WeakCell> cell = code->GetIsolate()->factory()->NewWeakCell(code);
+ DeoptimizationInputData::cast(code->deoptimization_data())
+ ->SetWeakCellCache(*cell);
+ return cell;
+}
+
+
+WeakCell* Code::CachedWeakCell() {
+ DCHECK(kind() == OPTIMIZED_FUNCTION);
+ Object* weak_cell_cache =
+ DeoptimizationInputData::cast(deoptimization_data())->WeakCellCache();
+ if (weak_cell_cache->IsWeakCell()) {
+ DCHECK(this == WeakCell::cast(weak_cell_cache)->value());
+ return WeakCell::cast(weak_cell_cache);
+ }
+ return NULL;
+}
+
+
#ifdef ENABLE_DISASSEMBLER
void DeoptimizationInputData::DeoptimizationInputDataPrint(
« no previous file with comments | « src/objects.h ('k') | src/x64/lithium-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698