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

Side by Side Diff: src/api.cc

Issue 481043002: Get rid of LookupRealNamedProperty and LookupRealNamedPropertyInPrototypes and update clients (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/objects.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/api.h" 5 #include "src/api.h"
6 6
7 #include <string.h> // For memcpy, strlen. 7 #include <string.h> // For memcpy, strlen.
8 #ifdef V8_USE_ADDRESS_SANITIZER 8 #ifdef V8_USE_ADDRESS_SANITIZER
9 #include <sanitizer/asan_interface.h> 9 #include <sanitizer/asan_interface.h>
10 #endif // V8_USE_ADDRESS_SANITIZER 10 #endif // V8_USE_ADDRESS_SANITIZER
(...skipping 3546 matching lines...) Expand 10 before | Expand all | Expand 10 after
3557 3557
3558 3558
3559 bool v8::Object::HasIndexedLookupInterceptor() { 3559 bool v8::Object::HasIndexedLookupInterceptor() {
3560 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3560 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3561 ON_BAILOUT(isolate, "v8::Object::HasIndexedLookupInterceptor()", 3561 ON_BAILOUT(isolate, "v8::Object::HasIndexedLookupInterceptor()",
3562 return false); 3562 return false);
3563 return Utils::OpenHandle(this)->HasIndexedInterceptor(); 3563 return Utils::OpenHandle(this)->HasIndexedInterceptor();
3564 } 3564 }
3565 3565
3566 3566
3567 static Local<Value> GetPropertyByLookup(i::Isolate* isolate, 3567 static Local<Value> GetPropertyByLookup(i::LookupIterator* it) {
3568 i::Handle<i::JSObject> receiver, 3568 // If the property being looked up is a callback, it can throw an exception.
3569 i::Handle<i::String> name, 3569 EXCEPTION_PREAMBLE(it->isolate());
3570 i::LookupResult* lookup) {
3571 if (!lookup->IsProperty()) {
3572 // No real property was found.
3573 return Local<Value>();
3574 }
3575
3576 // If the property being looked up is a callback, it can throw
3577 // an exception.
3578 EXCEPTION_PREAMBLE(isolate);
3579 i::LookupIterator it(receiver, name,
3580 i::Handle<i::JSReceiver>(lookup->holder(), isolate),
3581 i::LookupIterator::CHECK_DERIVED_SKIP_INTERCEPTOR);
3582 i::Handle<i::Object> result; 3570 i::Handle<i::Object> result;
3583 has_pending_exception = !i::Object::GetProperty(&it).ToHandle(&result); 3571 has_pending_exception = !i::Object::GetProperty(it).ToHandle(&result);
3584 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>()); 3572 EXCEPTION_BAILOUT_CHECK(it->isolate(), Local<Value>());
3585 3573
3586 return Utils::ToLocal(result); 3574 return Utils::ToLocal(result);
3587 } 3575 }
3588 3576
3589 3577
3590 Local<Value> v8::Object::GetRealNamedPropertyInPrototypeChain( 3578 Local<Value> v8::Object::GetRealNamedPropertyInPrototypeChain(
3591 Handle<String> key) { 3579 Handle<String> key) {
3592 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3580 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3593 ON_BAILOUT(isolate, 3581 ON_BAILOUT(isolate,
3594 "v8::Object::GetRealNamedPropertyInPrototypeChain()", 3582 "v8::Object::GetRealNamedPropertyInPrototypeChain()",
3595 return Local<Value>()); 3583 return Local<Value>());
3596 ENTER_V8(isolate); 3584 ENTER_V8(isolate);
3597 i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this); 3585 i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this);
3598 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); 3586 i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
3599 i::LookupResult lookup(isolate); 3587 i::PrototypeIterator iter(isolate, self_obj);
3600 self_obj->LookupRealNamedPropertyInPrototypes(key_obj, &lookup); 3588 if (iter.IsAtEnd()) return Local<Value>();
3601 return GetPropertyByLookup(isolate, self_obj, key_obj, &lookup); 3589 i::LookupIterator it(i::PrototypeIterator::GetCurrent(iter), key_obj,
3590 i::LookupIterator::CHECK_DERIVED_PROPERTY);
3591 return GetPropertyByLookup(&it);
3602 } 3592 }
3603 3593
3604 3594
3605 Local<Value> v8::Object::GetRealNamedProperty(Handle<String> key) { 3595 Local<Value> v8::Object::GetRealNamedProperty(Handle<String> key) {
3606 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3596 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3607 ON_BAILOUT(isolate, "v8::Object::GetRealNamedProperty()", 3597 ON_BAILOUT(isolate, "v8::Object::GetRealNamedProperty()",
3608 return Local<Value>()); 3598 return Local<Value>());
3609 ENTER_V8(isolate); 3599 ENTER_V8(isolate);
3610 i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this); 3600 i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this);
3611 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); 3601 i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
3612 i::LookupResult lookup(isolate); 3602 i::LookupIterator it(self_obj, key_obj,
3613 self_obj->LookupRealNamedProperty(key_obj, &lookup); 3603 i::LookupIterator::CHECK_DERIVED_PROPERTY);
3614 return GetPropertyByLookup(isolate, self_obj, key_obj, &lookup); 3604 return GetPropertyByLookup(&it);
3615 } 3605 }
3616 3606
3617 3607
3618 // Turns on access checks by copying the map and setting the check flag. 3608 // Turns on access checks by copying the map and setting the check flag.
3619 // Because the object gets a new map, existing inline cache caching 3609 // Because the object gets a new map, existing inline cache caching
3620 // the old map of this object will fail. 3610 // the old map of this object will fail.
3621 void v8::Object::TurnOnAccessCheck() { 3611 void v8::Object::TurnOnAccessCheck() {
3622 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3612 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3623 ON_BAILOUT(isolate, "v8::Object::TurnOnAccessCheck()", return); 3613 ON_BAILOUT(isolate, "v8::Object::TurnOnAccessCheck()", return);
3624 ENTER_V8(isolate); 3614 ENTER_V8(isolate);
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
4058 Handle<Value> Function::GetDisplayName() const { 4048 Handle<Value> Function::GetDisplayName() const {
4059 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 4049 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
4060 ON_BAILOUT(isolate, "v8::Function::GetDisplayName()", 4050 ON_BAILOUT(isolate, "v8::Function::GetDisplayName()",
4061 return ToApiHandle<Primitive>( 4051 return ToApiHandle<Primitive>(
4062 isolate->factory()->undefined_value())); 4052 isolate->factory()->undefined_value()));
4063 ENTER_V8(isolate); 4053 ENTER_V8(isolate);
4064 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); 4054 i::Handle<i::JSFunction> func = Utils::OpenHandle(this);
4065 i::Handle<i::String> property_name = 4055 i::Handle<i::String> property_name =
4066 isolate->factory()->InternalizeOneByteString( 4056 isolate->factory()->InternalizeOneByteString(
4067 STATIC_ASCII_VECTOR("displayName")); 4057 STATIC_ASCII_VECTOR("displayName"));
4068 i::LookupResult lookup(isolate); 4058 i::LookupIterator it(func, property_name,
aandrey 2014/08/19 16:01:15 this var is not used, or does it behave like a sco
Toon Verwaest 2014/08/19 16:04:48 I just realized, hence https://codereview.chromium
4069 func->LookupRealNamedProperty(property_name, &lookup); 4059 i::LookupIterator::CHECK_DERIVED_PROPERTY);
4070 if (lookup.IsFound()) { 4060
4071 i::Object* value = lookup.GetLazyValue(); 4061 i::Handle<i::Object> value =
4072 if (value && value->IsString()) { 4062 i::JSObject::GetDataProperty(func, property_name);
aandrey 2014/08/19 16:01:15 this should not result in any side effects, like c
Toon Verwaest 2014/08/19 16:04:48 Yes, that's what GetDataProperty is for.
4073 i::String* name = i::String::cast(value); 4063 if (value->IsString()) {
4074 if (name->length() > 0) return Utils::ToLocal(i::Handle<i::String>(name)); 4064 i::Handle<i::String> name = i::Handle<i::String>::cast(value);
4075 } 4065 if (name->length() > 0) return Utils::ToLocal(name);
4076 } 4066 }
4067
4077 return ToApiHandle<Primitive>(isolate->factory()->undefined_value()); 4068 return ToApiHandle<Primitive>(isolate->factory()->undefined_value());
4078 } 4069 }
4079 4070
4080 4071
4081 ScriptOrigin Function::GetScriptOrigin() const { 4072 ScriptOrigin Function::GetScriptOrigin() const {
4082 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); 4073 i::Handle<i::JSFunction> func = Utils::OpenHandle(this);
4083 if (func->shared()->script()->IsScript()) { 4074 if (func->shared()->script()->IsScript()) {
4084 i::Handle<i::Script> script(i::Script::cast(func->shared()->script())); 4075 i::Handle<i::Script> script(i::Script::cast(func->shared()->script()));
4085 i::Handle<i::Object> scriptName = i::Script::GetNameOrSourceURL(script); 4076 i::Handle<i::Object> scriptName = i::Script::GetNameOrSourceURL(script);
4086 v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(func->GetIsolate()); 4077 v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(func->GetIsolate());
(...skipping 3558 matching lines...) Expand 10 before | Expand all | Expand 10 after
7645 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7636 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7646 Address callback_address = 7637 Address callback_address =
7647 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7638 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7648 VMState<EXTERNAL> state(isolate); 7639 VMState<EXTERNAL> state(isolate);
7649 ExternalCallbackScope call_scope(isolate, callback_address); 7640 ExternalCallbackScope call_scope(isolate, callback_address);
7650 callback(info); 7641 callback(info);
7651 } 7642 }
7652 7643
7653 7644
7654 } } // namespace v8::internal 7645 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698