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

Unified Diff: src/runtime/runtime-object.cc

Issue 1402393003: Ensure JSProxy correctness for PrototypeIterator uses (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: reword comment Created 5 years, 1 month 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/objects.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime/runtime-object.cc
diff --git a/src/runtime/runtime-object.cc b/src/runtime/runtime-object.cc
index 28726cba56672788e404fa8a0e72af92cd48ec54..8d05fdd911577c1472cee19f0ee090ebaeb1862a 100644
--- a/src/runtime/runtime-object.cc
+++ b/src/runtime/runtime-object.cc
@@ -629,6 +629,8 @@ static Object* HasOwnPropertyImplementation(Isolate* isolate,
->is_hidden_prototype()) {
// TODO(verwaest): The recursion is not necessary for keys that are array
// indices. Removing this.
+ // Casting to JSObject is fine because JSProxies are never used as
+ // hidden prototypes.
return HasOwnPropertyImplementation(
isolate, Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)),
key);
@@ -769,8 +771,9 @@ RUNTIME_FUNCTION(Runtime_GetOwnPropertyNames) {
for (PrototypeIterator iter(isolate, object,
PrototypeIterator::START_AT_RECEIVER);
!iter.IsAtEnd(PrototypeIterator::END_AT_NON_HIDDEN); iter.Advance()) {
- Handle<JSObject> jsproto =
- Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter));
+ // Casting to JSObject is fine because |object| is guaranteed to be one,
+ // and we'll only look at hidden prototypes which are never JSProxies.
+ Handle<JSObject> jsproto = PrototypeIterator::GetCurrent<JSObject>(iter);
total_property_count += jsproto->NumberOfOwnProperties(filter);
}
@@ -785,8 +788,9 @@ RUNTIME_FUNCTION(Runtime_GetOwnPropertyNames) {
for (PrototypeIterator iter(isolate, object,
PrototypeIterator::START_AT_RECEIVER);
!iter.IsAtEnd(PrototypeIterator::END_AT_NON_HIDDEN); iter.Advance()) {
- Handle<JSObject> jsproto =
- Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter));
+ // Casting to JSObject is fine because |object| is guaranteed to be one,
+ // and we'll only look at hidden prototypes which are never JSProxies.
+ Handle<JSObject> jsproto = PrototypeIterator::GetCurrent<JSObject>(iter);
int own = jsproto->GetOwnPropertyNames(*names, next_copy_index, filter);
// Names from hidden prototypes may already have been added
// for inherited function template instances. Count the duplicates
@@ -870,6 +874,8 @@ RUNTIME_FUNCTION(Runtime_GetOwnElementNames) {
if (iter.IsAtEnd(PrototypeIterator::END_AT_NON_HIDDEN)) {
return *isolate->factory()->NewJSArray(0);
}
+ // Casting to JSObject is fine because |object| is guaranteed to be one,
+ // and we'll only look at hidden prototypes which are never JSProxies.
object = PrototypeIterator::GetCurrent<JSObject>(iter);
}
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698