Reviewers: mvstanton,
Message:
Quadratic algorithm is being quadratic.
Description:
Remove duplicate code for searching SharedFunctionInfo.
[email protected]
Please review this at https://codereview.chromium.org/762123002/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+4, -22 lines):
M src/ast.cc
M src/compiler/ast-graph-builder.cc
Index: src/ast.cc
diff --git a/src/ast.cc b/src/ast.cc
index
874f984ff6bc61a4bcb470b097e67a44795171fd..5659dbb9a395fde93d159098246fbe976f347b51
100644
--- a/src/ast.cc
+++ b/src/ast.cc
@@ -157,6 +157,8 @@ bool FunctionLiteral::uses_super() const {
}
+// Helper to find an existing shared function info in the baseline code
for the
+// given function literal. Used to canonicalize SharedFunctionInfo objects.
void FunctionLiteral::InitializeSharedInfo(
Handle<Code> unoptimized_code) {
for (RelocIterator it(*unoptimized_code); !it.done(); it.next()) {
Index: src/compiler/ast-graph-builder.cc
diff --git a/src/compiler/ast-graph-builder.cc
b/src/compiler/ast-graph-builder.cc
index
afe331df377b1829f9d0e3c7308c2b573241c710..4ecbda764bf6402a628459988e4325cf3d61e0c2
100644
--- a/src/compiler/ast-graph-builder.cc
+++ b/src/compiler/ast-graph-builder.cc
@@ -148,26 +148,6 @@ static LhsKind DetermineLhsKind(Expression* expr) {
}
-// Helper to find an existing shared function info in the baseline code
for the
-// given function literal. Used to canonicalize SharedFunctionInfo objects.
-static Handle<SharedFunctionInfo> SearchSharedFunctionInfo(
- Code* unoptimized_code, FunctionLiteral* expr) {
- int start_position = expr->start_position();
- for (RelocIterator it(unoptimized_code); !it.done(); it.next()) {
- RelocInfo* rinfo = it.rinfo();
- if (rinfo->rmode() != RelocInfo::EMBEDDED_OBJECT) continue;
- Object* obj = rinfo->target_object();
- if (obj->IsSharedFunctionInfo()) {
- SharedFunctionInfo* shared = SharedFunctionInfo::cast(obj);
- if (shared->start_position() == start_position) {
- return Handle<SharedFunctionInfo>(shared);
- }
- }
- }
- return Handle<SharedFunctionInfo>();
-}
-
-
StructuredGraphBuilder::Environment* AstGraphBuilder::CopyEnvironment(
StructuredGraphBuilder::Environment* env) {
return new (zone()) Environment(*reinterpret_cast<Environment*>(env));
@@ -835,8 +815,8 @@ void
AstGraphBuilder::VisitFunctionLiteral(FunctionLiteral* expr) {
// Build a new shared function info if we cannot find one in the baseline
// code. We also have a stack overflow if the recursive compilation did.
- Handle<SharedFunctionInfo> shared_info =
- SearchSharedFunctionInfo(info()->shared_info()->code(), expr);
+ expr->InitializeSharedInfo(handle(info()->shared_info()->code()));
+ Handle<SharedFunctionInfo> shared_info = expr->shared_info();
if (shared_info.is_null()) {
shared_info = Compiler::BuildFunctionInfo(expr, info()->script(),
info());
CHECK(!shared_info.is_null()); // TODO(mstarzinger): Set stack
overflow?
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.