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

Unified Diff: src/ia32/codegen-ia32.cc

Issue 660077: NOT FOR COMMITTING: Add fast side-effect free floating point expressions. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 10 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/ia32/codegen-ia32.h ('k') | src/ia32/safe-codegen-ia32.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ia32/codegen-ia32.cc
===================================================================
--- src/ia32/codegen-ia32.cc (revision 3987)
+++ src/ia32/codegen-ia32.cc (working copy)
@@ -38,6 +38,7 @@
#include "regexp-stack.h"
#include "register-allocator-inl.h"
#include "runtime.h"
+#include "safe-codegen-ia32.h"
#include "scopes.h"
#include "virtual-frame-inl.h"
@@ -589,6 +590,31 @@
}
+void CodeGenerator::LoadPossiblySafeExpression(Expression* expr) {
+ SafeSyntaxChecker checker;
+ if (checker.Check(expr)) {
+ __ IncrementCounter(&Counters::safe_expression_tried, 1);
+ JumpTarget unsafe;
+ JumpTarget done;
+ Result scratch = allocator_->Allocate();
+ ASSERT(scratch.is_register());
+ Result result = allocator_->Allocate();
+ ASSERT(result.is_register());
+ SafeGenerator safe_generator(masm_, &unsafe, this, &scratch, &result);
+ result = safe_generator.Generate(expr);
+ frame()->Push(&result);
+ __ IncrementCounter(&Counters::safe_expression_succeeded, 1);
+ done.Jump();
+
+ unsafe.Bind();
+ Load(expr);
+ done.Bind();
+ } else {
+ Load(expr);
+ }
+}
+
+
ArgumentsAllocationMode CodeGenerator::ArgumentsMode() {
if (scope()->arguments() == NULL) return NO_ARGUMENTS_ALLOCATION;
ASSERT(scope()->arguments_shadow() != NULL);
@@ -2922,7 +2948,7 @@
Comment cmnt(masm_, "[ ReturnStatement");
CodeForStatementPosition(node);
- Load(node->expression());
+ LoadPossiblySafeExpression(node->expression());
Result return_value = frame_->Pop();
masm()->WriteRecordedPositions();
if (function_return_is_shadowed_) {
@@ -4745,7 +4771,7 @@
if (node->is_compound()) {
Result result = LoadFromSlotCheckForArguments(slot, NOT_INSIDE_TYPEOF);
frame()->Push(&result);
- Load(node->value());
+ LoadPossiblySafeExpression(node->value());
bool overwrite_value =
(node->value()->AsBinaryOperation() != NULL &&
@@ -4754,7 +4780,7 @@
node->type(),
overwrite_value ? OVERWRITE_RIGHT : NO_OVERWRITE);
} else {
- Load(node->value());
+ LoadPossiblySafeExpression(node->value());
}
// Perform the assignment.
@@ -4822,7 +4848,7 @@
}
Result value = EmitNamedLoad(name, var != NULL);
frame()->Push(&value);
- Load(node->value());
+ LoadPossiblySafeExpression(node->value());
bool overwrite_value =
(node->value()->AsBinaryOperation() != NULL &&
@@ -4831,7 +4857,7 @@
node->type(),
overwrite_value ? OVERWRITE_RIGHT : NO_OVERWRITE);
} else {
- Load(node->value());
+ LoadPossiblySafeExpression(node->value());
}
// Perform the assignment. It is safe to ignore constants here.
@@ -4901,7 +4927,7 @@
frame()->PushElementAt(1);
Result value = EmitKeyedLoad();
frame()->Push(&value);
- Load(node->value());
+ LoadPossiblySafeExpression(node->value());
bool overwrite_value =
(node->value()->AsBinaryOperation() != NULL &&
@@ -4910,7 +4936,7 @@
node->type(),
overwrite_value ? OVERWRITE_RIGHT : NO_OVERWRITE);
} else {
- Load(node->value());
+ LoadPossiblySafeExpression(node->value());
}
// Perform the assignment. It is safe to ignore constants here.
@@ -5020,7 +5046,7 @@
frame_->Push(Factory::undefined_value());
int arg_count = args->length();
for (int i = 0; i < arg_count; i++) {
- Load(args->at(i));
+ LoadPossiblySafeExpression(args->at(i));
}
// Prepare the stack for the call to ResolvePossiblyDirectEval.
@@ -5069,7 +5095,7 @@
// Load the arguments.
int arg_count = args->length();
for (int i = 0; i < arg_count; i++) {
- Load(args->at(i));
+ LoadPossiblySafeExpression(args->at(i));
}
// Push the name of the function onto the frame.
@@ -5140,7 +5166,7 @@
// Load the arguments.
int arg_count = args->length();
for (int i = 0; i < arg_count; i++) {
- Load(args->at(i));
+ LoadPossiblySafeExpression(args->at(i));
}
// Push the name of the function onto the frame.
« no previous file with comments | « src/ia32/codegen-ia32.h ('k') | src/ia32/safe-codegen-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698