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

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: 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') | test/cctest/test-heap.cc » ('J')
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 be18b3b7a182f010a177b875ab000002d4b8a31a..aa0c8a67b4808bb3a84da8bcc2743482d1a25752 100644
--- a/src/lookup.cc
+++ b/src/lookup.cc
@@ -59,13 +59,23 @@ void LookupIterator::RestartLookupForNonMaskingInterceptors() {
}
-Handle<JSReceiver> LookupIterator::GetRoot(Handle<Object> receiver,
- Isolate* isolate) {
- if (receiver->IsJSReceiver()) return Handle<JSReceiver>::cast(receiver);
- auto root = handle(receiver->GetRootMap(isolate)->prototype(), isolate);
+Handle<JSReceiver> LookupIterator::GetRoot() {
Igor Sheludko 2015/07/10 10:02:42 I think it is better to keep GetRoot() static give
+ 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 (IsElement() && 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 = 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;
- isolate->PushStackTraceAndDie(magic, *receiver, NULL, magic);
+ isolate_->PushStackTraceAndDie(magic, *receiver_, NULL, magic);
}
return Handle<JSReceiver>::cast(root);
}
« no previous file with comments | « src/lookup.h ('k') | src/objects.h » ('j') | test/cctest/test-heap.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698