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

Unified Diff: src/lookup.cc

Issue 1221303019: Fix keyed access of primitive objects in the runtime. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix Created 5 years, 5 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/lookup.h ('k') | src/objects.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/lookup.cc
diff --git a/src/lookup.cc b/src/lookup.cc
index d731a7c8ff539c85500a4861c578bce7c78245a1..330d5cad0ab2db0de7b2851cb82ca03c9deb7581 100644
--- a/src/lookup.cc
+++ b/src/lookup.cc
@@ -59,9 +59,22 @@ void LookupIterator::RestartLookupForNonMaskingInterceptors() {
}
-Handle<JSReceiver> LookupIterator::GetRoot(Handle<Object> receiver,
- Isolate* isolate) {
+// static
+Handle<JSReceiver> LookupIterator::GetRoot(Isolate* isolate,
+ Handle<Object> receiver,
+ uint32_t index) {
if (receiver->IsJSReceiver()) return Handle<JSReceiver>::cast(receiver);
+ // Strings are the only objects with properties (only elements) directly on
+ // the wrapper. Hence we can skip generating the wrapper for all other cases.
+ if (index != kMaxUInt32 && receiver->IsString() &&
+ index < static_cast<uint32_t>(String::cast(*receiver)->length())) {
+ // TODO(verwaest): Speed this up. Perhaps use a cached wrapper on the native
+ // context, ensuring that we don't leak it into JS?
+ Handle<JSFunction> constructor = isolate->string_function();
+ Handle<JSObject> result = isolate->factory()->NewJSObject(constructor);
+ Handle<JSValue>::cast(result)->set_value(*receiver);
+ return result;
+ }
auto root = handle(receiver->GetRootMap(isolate)->prototype(), isolate);
if (root->IsNull()) {
unsigned int magic = 0xbbbbbbbb;
« no previous file with comments | « src/lookup.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698