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

Unified Diff: src/ic.cc

Issue 11941016: Migrate FunctionPrototype (Keyed|Named)LoadIC to CodeStub (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 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/ia32/stub-cache-ia32.cc ('k') | src/stub-cache.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 09a918f0a57adb79dbc1b45b5ede7cb4ba3e44d1..83cb4389885541d361b65102f1dfc7adb0cb659d 100644
--- a/src/ic.cc
+++ b/src/ic.cc
@@ -836,78 +836,61 @@ bool IC::HandleLoad(State state,
Handle<Object> object,
Handle<String> name,
MaybeObject** result) {
- // Use specialized code for getting the length of strings and
- // string wrapper objects. The length property of string wrapper
- // objects is read-only and therefore always returns the length of
- // the underlying string value. See ECMA-262 15.5.5.1.
- if ((object->IsString() || object->IsStringWrapper()) &&
- name->Equals(isolate()->heap()->length_symbol())) {
- Handle<Code> stub;
- if (state == UNINITIALIZED) {
- stub = pre_monomorphic_stub();
- } else if (state == PREMONOMORPHIC) {
- StringLengthStub string_length_stub(kind(), !object->IsString());
- stub = string_length_stub.GetCode();
- } else if (state == MONOMORPHIC && object->IsStringWrapper()) {
- StringLengthStub string_length_stub(kind(), true);
- stub = string_length_stub.GetCode();
- } else if (state != MEGAMORPHIC) {
- ASSERT(state != GENERIC);
- stub = megamorphic_stub();
- }
- if (!stub.is_null()) {
- set_target(*stub);
+ if (FLAG_use_ic) {
+ // Use specialized code for getting the length of strings and
+ // string wrapper objects. The length property of string wrapper
+ // objects is read-only and therefore always returns the length of
+ // the underlying string value. See ECMA-262 15.5.5.1.
+ if ((object->IsString() || object->IsStringWrapper()) &&
+ name->Equals(isolate()->heap()->length_symbol())) {
+ Handle<Code> stub;
+ if (state == UNINITIALIZED) {
+ stub = pre_monomorphic_stub();
+ } else if (state == PREMONOMORPHIC) {
+ StringLengthStub string_length_stub(kind(), !object->IsString());
+ stub = string_length_stub.GetCode();
+ } else if (state == MONOMORPHIC && object->IsStringWrapper()) {
+ StringLengthStub string_length_stub(kind(), true);
+ stub = string_length_stub.GetCode();
+ } else if (state != MEGAMORPHIC) {
+ ASSERT(state != GENERIC);
+ stub = megamorphic_stub();
+ }
+ if (!stub.is_null()) {
+ set_target(*stub);
#ifdef DEBUG
- if (FLAG_trace_ic) PrintF("[LoadIC : +#length /string]\n");
+ if (FLAG_trace_ic) PrintF("[LoadIC : +#length /string]\n");
#endif
+ }
+ // Get the string if we have a string wrapper object.
+ Handle<Object> string = object->IsJSValue()
+ ? Handle<Object>(Handle<JSValue>::cast(object)->value())
+ : object;
+ *result = Smi::FromInt(String::cast(*string)->length());
+ return true;
}
- // Get the string if we have a string wrapper object.
- Handle<Object> string = object->IsJSValue()
- ? Handle<Object>(Handle<JSValue>::cast(object)->value())
- : object;
- *result = Smi::FromInt(String::cast(*string)->length());
- return true;
- }
- // Use specialized code for getting the length of arrays.
- if (object->IsJSArray() && name->Equals(isolate()->heap()->length_symbol())) {
- Handle<Code> stub;
- if (state == UNINITIALIZED) {
- stub = pre_monomorphic_stub();
- } else if (state == PREMONOMORPHIC) {
- ArrayLengthStub array_length_stub(kind());
- stub = array_length_stub.GetCode();
- } else if (state != MEGAMORPHIC) {
- ASSERT(state != GENERIC);
- stub = megamorphic_stub();
- }
- if (!stub.is_null()) {
- set_target(*stub);
+ // Use specialized code for getting the length of arrays.
+ if (object->IsJSArray() &&
+ name->Equals(isolate()->heap()->length_symbol())) {
+ Handle<Code> stub;
+ if (state == UNINITIALIZED) {
+ stub = pre_monomorphic_stub();
+ } else if (state == PREMONOMORPHIC) {
+ ArrayLengthStub array_length_stub(kind());
+ stub = array_length_stub.GetCode();
+ } else if (state != MEGAMORPHIC) {
+ ASSERT(state != GENERIC);
+ stub = megamorphic_stub();
+ }
+ if (!stub.is_null()) {
+ set_target(*stub);
#ifdef DEBUG
- if (FLAG_trace_ic) PrintF("[LoadIC : +#length /array]\n");
+ if (FLAG_trace_ic) PrintF("[LoadIC : +#length /array]\n");
#endif
- }
- *result = JSArray::cast(*object)->length();
- return true;
- }
-
- return false;
-}
-
-
-MaybeObject* LoadIC::Load(State state,
- Handle<Object> object,
- Handle<String> name) {
- // If the object is undefined or null it's illegal to try to get any
- // of its properties; throw a TypeError in that case.
- if (object->IsUndefined() || object->IsNull()) {
- return TypeError("non_object_property_load", object, name);
- }
-
- if (FLAG_use_ic) {
- MaybeObject* result;
- if (HandleLoad(state, object, name, &result)) {
- return result;
+ }
+ *result = JSArray::cast(*object)->length();
+ return true;
}
// Use specialized code for getting prototype of functions.
@@ -918,7 +901,8 @@ MaybeObject* LoadIC::Load(State state,
if (state == UNINITIALIZED) {
stub = pre_monomorphic_stub();
} else if (state == PREMONOMORPHIC) {
- stub = isolate()->builtins()->LoadIC_FunctionPrototype();
+ FunctionPrototypeStub function_prototype_stub(kind());
+ stub = function_prototype_stub.GetCode();
} else if (state != MEGAMORPHIC) {
ASSERT(state != GENERIC);
stub = megamorphic_stub();
@@ -929,10 +913,29 @@ MaybeObject* LoadIC::Load(State state,
if (FLAG_trace_ic) PrintF("[LoadIC : +#prototype /function]\n");
#endif
}
- return Accessors::FunctionGetPrototype(*object, 0);
+ *result = Accessors::FunctionGetPrototype(*object, 0);
+ return true;
}
}
+ return false;
+}
+
+
+MaybeObject* LoadIC::Load(State state,
+ Handle<Object> object,
+ Handle<String> name) {
+ // If the object is undefined or null it's illegal to try to get any
+ // of its properties; throw a TypeError in that case.
+ if (object->IsUndefined() || object->IsNull()) {
+ return TypeError("non_object_property_load", object, name);
+ }
+
+ MaybeObject* result;
+ if (HandleLoad(state, object, name, &result)) {
+ return result;
+ }
+
// Check if the name is trivially convertible to an index and get
// the element if so.
uint32_t index;
@@ -1170,26 +1173,9 @@ MaybeObject* KeyedLoadIC::Load(State state,
return TypeError("non_object_property_load", object, name);
}
- if (FLAG_use_ic) {
- MaybeObject* result;
- if (HandleLoad(state, object, name, &result)) {
- return result;
- }
-
- // TODO(1073): don't ignore the current stub state.
- // Use specialized code for getting prototype of functions.
- if (object->IsJSFunction() &&
- name->Equals(isolate()->heap()->prototype_symbol()) &&
- Handle<JSFunction>::cast(object)->should_have_prototype()) {
- Handle<JSFunction> function = Handle<JSFunction>::cast(object);
- Handle<Code> code =
- isolate()->stub_cache()->ComputeKeyedLoadFunctionPrototype(
- name, function);
- ASSERT(!code.is_null());
- set_target(*code);
- TRACE_IC("KeyedLoadIC", name, state, target());
- return Accessors::FunctionGetPrototype(*object, 0);
- }
+ MaybeObject* result;
+ if (HandleLoad(state, object, name, &result)) {
+ return result;
}
// Check if the name is trivially convertible to an index and get
« no previous file with comments | « src/ia32/stub-cache-ia32.cc ('k') | src/stub-cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698