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

Unified Diff: src/ic/ic.cc

Issue 1168093002: [strong] Implement strong mode restrictions on property access (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase Created 5 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/ic.h ('k') | src/ic/ic-compiler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ic/ic.cc
diff --git a/src/ic/ic.cc b/src/ic/ic.cc
index 7c14b5625beb49203ee114964068d6a8cb6e1bad..5499d805428ccf5f01e616b61f1eeddc874e6aff 100644
--- a/src/ic/ic.cc
+++ b/src/ic/ic.cc
@@ -571,11 +571,14 @@ void CompareIC::Clear(Isolate* isolate, Address address, Code* target,
// static
-Handle<Code> KeyedLoadIC::ChooseMegamorphicStub(Isolate* isolate) {
+Handle<Code> KeyedLoadIC::ChooseMegamorphicStub(Isolate* isolate,
+ ExtraICState extra_state) {
if (FLAG_compiled_keyed_generic_loads) {
- return KeyedLoadGenericStub(isolate).GetCode();
+ return KeyedLoadGenericStub(isolate, LoadICState(extra_state)).GetCode();
} else {
- return isolate->builtins()->KeyedLoadIC_Megamorphic();
+ return is_strong(LoadICState::GetLanguageMode(extra_state))
+ ? isolate->builtins()->KeyedLoadIC_Megamorphic_Strong()
+ : isolate->builtins()->KeyedLoadIC_Megamorphic();
}
}
@@ -679,7 +682,8 @@ MaybeHandle<Object> LoadIC::Load(Handle<Object> object, Handle<Name> name) {
Handle<Object> result;
ASSIGN_RETURN_ON_EXCEPTION(
isolate(), result,
- Runtime::GetElementOrCharAt(isolate(), object, index), Object);
+ Runtime::GetElementOrCharAt(isolate(), object, index, language_mode()),
+ Object);
return result;
}
@@ -722,8 +726,9 @@ MaybeHandle<Object> LoadIC::Load(Handle<Object> object, Handle<Name> name) {
// Get the property.
Handle<Object> result;
- ASSIGN_RETURN_ON_EXCEPTION(isolate(), result, Object::GetProperty(&it),
- Object);
+
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate(), result, Object::GetProperty(&it, language_mode()), Object);
if (it.IsFound()) {
return result;
} else if (!IsUndeclaredGlobal(object)) {
@@ -915,25 +920,20 @@ Handle<Code> LoadIC::initialize_stub_in_optimized_code(
}
-Handle<Code> KeyedLoadIC::initialize_stub(Isolate* isolate) {
- return KeyedLoadICTrampolineStub(isolate).GetCode();
+Handle<Code> KeyedLoadIC::initialize_stub(Isolate* isolate,
+ ExtraICState extra_state) {
+ return KeyedLoadICTrampolineStub(isolate, LoadICState(extra_state)).GetCode();
}
Handle<Code> KeyedLoadIC::initialize_stub_in_optimized_code(
- Isolate* isolate, State initialization_state) {
+ Isolate* isolate, State initialization_state, ExtraICState extra_state) {
if (initialization_state != MEGAMORPHIC) {
- return KeyedLoadICStub(isolate).GetCode();
+ return KeyedLoadICStub(isolate, LoadICState(extra_state)).GetCode();
}
- switch (initialization_state) {
- case UNINITIALIZED:
- return isolate->builtins()->KeyedLoadIC_Initialize();
- case MEGAMORPHIC:
- return isolate->builtins()->KeyedLoadIC_Megamorphic();
- default:
- UNREACHABLE();
- }
- return Handle<Code>();
+ return is_strong(LoadICState::GetLanguageMode(extra_state))
+ ? isolate->builtins()->KeyedLoadIC_Megamorphic_Strong()
+ : isolate->builtins()->KeyedLoadIC_Megamorphic();
}
@@ -962,7 +962,7 @@ Handle<Code> KeyedStoreIC::initialize_stub(Isolate* isolate,
Handle<Code> LoadIC::megamorphic_stub() {
DCHECK_EQ(Code::KEYED_LOAD_IC, kind());
- return KeyedLoadIC::ChooseMegamorphicStub(isolate());
+ return KeyedLoadIC::ChooseMegamorphicStub(isolate(), extra_ic_state());
}
@@ -986,7 +986,7 @@ void LoadIC::UpdateCaches(LookupIterator* lookup) {
lookup->state() == LookupIterator::ACCESS_CHECK) {
code = slow_stub();
} else if (!lookup->IsFound()) {
- if (kind() == Code::LOAD_IC) {
+ if (kind() == Code::LOAD_IC && !is_strong(language_mode())) {
code = NamedLoadHandlerCompiler::ComputeLoadNonexistent(lookup->name(),
receiver_map());
// TODO(jkummerow/verwaest): Introduce a builtin that handles this case.
@@ -1245,7 +1245,8 @@ Handle<Code> KeyedLoadIC::LoadElementStub(Handle<HeapObject> receiver) {
if (target_receiver_maps.length() == 0) {
Handle<Code> handler =
- PropertyICCompiler::ComputeKeyedLoadMonomorphicHandler(receiver_map);
+ PropertyICCompiler::ComputeKeyedLoadMonomorphicHandler(
+ receiver_map, extra_ic_state());
ConfigureVectorState(Handle<Name>::null(), receiver_map, handler);
return null_handle;
}
@@ -1262,7 +1263,8 @@ Handle<Code> KeyedLoadIC::LoadElementStub(Handle<HeapObject> receiver) {
target_receiver_maps.at(0)->elements_kind(),
Handle<JSObject>::cast(receiver)->GetElementsKind())) {
Handle<Code> handler =
- PropertyICCompiler::ComputeKeyedLoadMonomorphicHandler(receiver_map);
+ PropertyICCompiler::ComputeKeyedLoadMonomorphicHandler(
+ receiver_map, extra_ic_state());
ConfigureVectorState(Handle<Name>::null(), receiver_map, handler);
return null_handle;
}
@@ -1287,7 +1289,8 @@ Handle<Code> KeyedLoadIC::LoadElementStub(Handle<HeapObject> receiver) {
CodeHandleList handlers(target_receiver_maps.length());
ElementHandlerCompiler compiler(isolate());
- compiler.CompileElementHandlers(&target_receiver_maps, &handlers);
+ compiler.CompileElementHandlers(&target_receiver_maps, &handlers,
+ language_mode());
ConfigureVectorState(Handle<Name>::null(), &target_receiver_maps, &handlers);
return null_handle;
}
@@ -1298,7 +1301,8 @@ MaybeHandle<Object> KeyedLoadIC::Load(Handle<Object> object,
if (MigrateDeprecated(object)) {
Handle<Object> result;
ASSIGN_RETURN_ON_EXCEPTION(
- isolate(), result, Runtime::GetObjectProperty(isolate(), object, key),
+ isolate(), result,
+ Runtime::GetObjectProperty(isolate(), object, key, language_mode()),
Object);
return result;
}
@@ -1346,10 +1350,12 @@ MaybeHandle<Object> KeyedLoadIC::Load(Handle<Object> object,
}
if (!load_handle.is_null()) return load_handle;
+
Handle<Object> result;
- ASSIGN_RETURN_ON_EXCEPTION(isolate(), result,
- Runtime::GetObjectProperty(isolate(), object, key),
- Object);
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate(), result,
+ Runtime::GetObjectProperty(isolate(), object, key, language_mode()),
+ Object);
return result;
}
@@ -2812,6 +2818,7 @@ RUNTIME_FUNCTION(LoadPropertyWithInterceptor) {
Handle<Object> result;
LookupIterator it(receiver, name, holder);
+ // TODO(conradw): Investigate strong mode semantics for this.
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
JSObject::GetProperty(&it));
@@ -2857,8 +2864,11 @@ RUNTIME_FUNCTION(LoadElementWithInterceptor) {
DCHECK(args.smi_at(1) >= 0);
uint32_t index = args.smi_at(1);
Handle<Object> result;
+ // TODO(conradw): Investigate strong mode semantics for this.
+ LanguageMode language_mode = SLOPPY;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result, Object::GetElement(isolate, receiver, index));
+ isolate, result,
+ Object::GetElement(isolate, receiver, index, language_mode));
return *result;
}
@@ -2894,6 +2904,36 @@ RUNTIME_FUNCTION(LoadIC_MissFromStubFailure) {
}
+RUNTIME_FUNCTION(LoadIC_Slow) {
+ HandleScope scope(isolate);
+ DCHECK(args.length() == 2);
+
+ Handle<Object> receiver = args.at<Object>(0);
+ Handle<Name> name = args.at<Name>(1);
+ LoadIC ic(IC::NO_EXTRA_FRAME, isolate, true);
+ Handle<Object> result;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, result,
+ Runtime::GetObjectProperty(isolate, receiver, name, ic.language_mode()));
+ return *result;
+}
+
+
+RUNTIME_FUNCTION(KeyedLoadIC_Slow) {
+ HandleScope scope(isolate);
+ DCHECK(args.length() == 2);
+
+ Handle<Object> receiver = args.at<Object>(0);
+ Handle<Object> key = args.at<Object>(1);
+ LoadIC ic(IC::NO_EXTRA_FRAME, isolate, true);
+ Handle<Object> result;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, result, Runtime::KeyedGetObjectProperty(isolate, receiver, key,
+ ic.language_mode()));
+ return *result;
+}
+
+
static const Address IC_utilities[] = {
#define ADDR(name) FUNCTION_ADDR(name),
IC_UTIL_LIST(ADDR) NULL
@@ -2902,5 +2942,5 @@ static const Address IC_utilities[] = {
Address IC::AddressFromUtilityId(IC::UtilityId id) { return IC_utilities[id]; }
-} // namespace internal
-} // namespace v8
+}
+} // namespace v8::internal
« no previous file with comments | « src/ic/ic.h ('k') | src/ic/ic-compiler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698