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

Unified Diff: src/ic.cc

Issue 18650003: Revert "Convert UnaryOpStub to a HydrogenCodeStub" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/ic.h ('k') | src/objects.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ic.cc
diff --git a/src/ic.cc b/src/ic.cc
index 8c1df539106ee510f6501a30374a2866d8a9a3bd..ff3a94d18c1f6dfdf32b22e3c1a10290e61cfcc0 100644
--- a/src/ic.cc
+++ b/src/ic.cc
@@ -2401,6 +2401,86 @@ RUNTIME_FUNCTION(MaybeObject*, KeyedStoreIC_MissForceGeneric) {
}
+void UnaryOpIC::patch(Code* code) {
+ set_target(code);
+}
+
+
+const char* UnaryOpIC::GetName(TypeInfo type_info) {
+ switch (type_info) {
+ case UNINITIALIZED: return "Uninitialized";
+ case SMI: return "Smi";
+ case NUMBER: return "Number";
+ case GENERIC: return "Generic";
+ default: return "Invalid";
+ }
+}
+
+
+UnaryOpIC::State UnaryOpIC::ToState(TypeInfo type_info) {
+ switch (type_info) {
+ case UNINITIALIZED:
+ return v8::internal::UNINITIALIZED;
+ case SMI:
+ case NUMBER:
+ return MONOMORPHIC;
+ case GENERIC:
+ return v8::internal::GENERIC;
+ }
+ UNREACHABLE();
+ return v8::internal::UNINITIALIZED;
+}
+
+
+Handle<Type> UnaryOpIC::TypeInfoToType(TypeInfo type_info, Isolate* isolate) {
+ switch (type_info) {
+ case UNINITIALIZED:
+ return handle(Type::None(), isolate);
+ case SMI:
+ return handle(Type::Smi(), isolate);
+ case NUMBER:
+ return handle(Type::Number(), isolate);
+ case GENERIC:
+ return handle(Type::Any(), isolate);
+ }
+ UNREACHABLE();
+ return handle(Type::Any(), isolate);
+}
+
+
+UnaryOpIC::TypeInfo UnaryOpIC::GetTypeInfo(Handle<Object> operand) {
+ v8::internal::TypeInfo operand_type =
+ v8::internal::TypeInfo::FromValue(operand);
+ if (operand_type.IsSmi()) {
+ return SMI;
+ } else if (operand_type.IsNumber()) {
+ return NUMBER;
+ } else {
+ return GENERIC;
+ }
+}
+
+
+UnaryOpIC::TypeInfo UnaryOpIC::ComputeNewType(
+ TypeInfo current_type,
+ TypeInfo previous_type) {
+ switch (previous_type) {
+ case UNINITIALIZED:
+ return current_type;
+ case SMI:
+ return (current_type == GENERIC) ? GENERIC : NUMBER;
+ case NUMBER:
+ return GENERIC;
+ case GENERIC:
+ // We should never do patching if we are in GENERIC state.
+ UNREACHABLE();
+ return GENERIC;
+ }
+ UNREACHABLE();
+ return GENERIC;
+}
+
+
void BinaryOpIC::patch(Code* code) {
set_target(code);
}
@@ -2478,24 +2558,57 @@ void BinaryOpIC::StubInfoToType(int minor_key,
}
-MaybeObject* UnaryOpIC::Transition(Handle<Object> object) {
- Code::ExtraICState extra_ic_state = target()->extended_extra_ic_state();
- UnaryOpStub stub(extra_ic_state);
+RUNTIME_FUNCTION(MaybeObject*, UnaryOp_Patch) {
+ ASSERT(args.length() == 4);
- stub.UpdateStatus(object);
+ HandleScope scope(isolate);
+ Handle<Object> operand = args.at<Object>(0);
+ Token::Value op = static_cast<Token::Value>(args.smi_at(1));
+ UnaryOverwriteMode mode = static_cast<UnaryOverwriteMode>(args.smi_at(2));
+ UnaryOpIC::TypeInfo previous_type =
+ static_cast<UnaryOpIC::TypeInfo>(args.smi_at(3));
- Handle<Code> code = stub.GetCode(isolate());
- set_target(*code);
+ UnaryOpIC::TypeInfo type = UnaryOpIC::GetTypeInfo(operand);
+ type = UnaryOpIC::ComputeNewType(type, previous_type);
- return stub.Result(object, isolate());
-}
+ UnaryOpStub stub(op, mode, type);
+ Handle<Code> code = stub.GetCode(isolate);
+ if (!code.is_null()) {
+ if (FLAG_trace_ic) {
+ PrintF("[UnaryOpIC in ");
+ JavaScriptFrame::PrintTop(isolate, stdout, false, true);
+ PrintF(" %s => %s #%s @ %p]\n",
+ UnaryOpIC::GetName(previous_type),
+ UnaryOpIC::GetName(type),
+ Token::Name(op),
+ static_cast<void*>(*code));
+ }
+ UnaryOpIC ic(isolate);
+ ic.patch(*code);
+ }
+
+ Handle<JSBuiltinsObject> builtins(isolate->js_builtins_object());
+ Object* builtin = NULL; // Initialization calms down the compiler.
+ switch (op) {
+ case Token::SUB:
+ builtin = builtins->javascript_builtin(Builtins::UNARY_MINUS);
+ break;
+ case Token::BIT_NOT:
+ builtin = builtins->javascript_builtin(Builtins::BIT_NOT);
+ break;
+ default:
+ UNREACHABLE();
+ }
+ Handle<JSFunction> builtin_function(JSFunction::cast(builtin), isolate);
-RUNTIME_FUNCTION(MaybeObject*, UnaryOpIC_Miss) {
- HandleScope scope(isolate);
- Handle<Object> object = args.at<Object>(0);
- UnaryOpIC ic(isolate);
- return ic.Transition(object);
+ bool caught_exception;
+ Handle<Object> result = Execution::Call(builtin_function, operand, 0, NULL,
+ &caught_exception);
+ if (caught_exception) {
+ return Failure::Exception();
+ }
+ return *result;
}
@@ -2956,7 +3069,9 @@ MaybeObject* CompareNilIC::CompareNil(Handle<Object> object) {
// types must be supported as a result of the miss.
bool already_monomorphic = stub.IsMonomorphic();
- stub.UpdateStatus(object);
+ CompareNilICStub::State old_state = stub.GetState();
+ stub.Record(object);
+ old_state.TraceTransition(stub.GetState());
NilValue nil = stub.GetNilValue();
@@ -2993,7 +3108,7 @@ RUNTIME_FUNCTION(MaybeObject*, Unreachable) {
MaybeObject* ToBooleanIC::ToBoolean(Handle<Object> object,
Code::ExtraICState extra_ic_state) {
ToBooleanStub stub(extra_ic_state);
- bool to_boolean_value = stub.UpdateStatus(object);
+ bool to_boolean_value = stub.Record(object);
Handle<Code> code = stub.GetCode(isolate());
set_target(*code);
return Smi::FromInt(to_boolean_value ? 1 : 0);
« no previous file with comments | « src/ic.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698