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

Unified Diff: src/objects.cc

Issue 1903463002: Make global eval faster by lazily computing its call position. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 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
« src/compiler.cc ('K') | « src/objects.h ('k') | no next file » | 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 5a6286593eacb53c32adbec9ffa5e6ed0731a69f..be76d127c0f42598dc2886f0d155b56c2e9546b7 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -12,9 +12,9 @@
#include "src/accessors.h"
#include "src/allocation-site-scopes.h"
-#include "src/api.h"
#include "src/api-arguments.h"
#include "src/api-natives.h"
+#include "src/api.h"
#include "src/base/bits.h"
#include "src/base/utils/random-number-generator.h"
#include "src/bootstrapper.h"
@@ -30,6 +30,7 @@
#include "src/field-index-inl.h"
#include "src/field-index.h"
#include "src/field-type.h"
+#include "src/frames-inl.h"
#include "src/full-codegen/full-codegen.h"
#include "src/ic/ic.h"
#include "src/identity-map.h"
@@ -13000,6 +13001,45 @@ void Oddball::Initialize(Isolate* isolate, Handle<Oddball> oddball,
oddball->set_kind(kind);
}
+void Script::SetEvalOrigin(Handle<Script> script,
+ Handle<SharedFunctionInfo> outer_info,
+ int eval_position) {
+ if (eval_position == RelocInfo::kNoPosition) {
+ // If the position is missing, attempt to get the code offset from the
+ // current activation. Do not translate the code offset into source
+ // position, but store it as negative value for lazy translation.
+ StackTraceFrameIterator it(script->GetIsolate());
+ if (!it.done() && it.is_javascript()) {
+ FrameSummary summary = FrameSummary::GetFirst(it.javascript_frame());
+ script->set_eval_from_shared(summary.function()->shared());
+ script->set_eval_from_position(-summary.code_offset());
+ return;
+ }
+ eval_position = 0;
+ }
+ script->set_eval_from_shared(*outer_info);
+ script->set_eval_from_position(eval_position);
+}
+
+int Script::GetEvalPosition() {
+ DisallowHeapAllocation no_gc;
+ DCHECK(compilation_type() == Script::COMPILATION_TYPE_EVAL);
+ int position = eval_from_position();
+ if (position < 0) {
+ // Due to laziness, the position may not have been translated from code
+ // offset yet, which would be encoded as negative integer. In that case,
+ // translate and set the position.
+ if (eval_from_shared()->IsUndefined()) {
+ position = 0;
+ } else {
+ SharedFunctionInfo* shared = SharedFunctionInfo::cast(eval_from_shared());
+ position = shared->abstract_code()->SourcePosition(-position);
+ }
+ DCHECK(position >= 0);
+ set_eval_from_position(position);
+ }
+ return position;
+}
void Script::InitLineEnds(Handle<Script> script) {
if (!script->line_ends()->IsUndefined()) return;
« src/compiler.cc ('K') | « src/objects.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698