OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 10 matching lines...) Expand all Loading... |
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #include "v8.h" | 28 #include "v8.h" |
29 | 29 |
30 #include "api.h" | 30 #include "api.h" |
| 31 #include "arguments.h" |
31 #include "bootstrapper.h" | 32 #include "bootstrapper.h" |
32 #include "debug.h" | 33 #include "debug.h" |
33 #include "execution.h" | 34 #include "execution.h" |
34 #include "objects-inl.h" | 35 #include "objects-inl.h" |
35 #include "macro-assembler.h" | 36 #include "macro-assembler.h" |
36 #include "scanner.h" | 37 #include "scanner.h" |
37 #include "scopeinfo.h" | 38 #include "scopeinfo.h" |
38 #include "string-stream.h" | 39 #include "string-stream.h" |
39 | 40 |
40 #ifdef ENABLE_DISASSEMBLER | 41 #ifdef ENABLE_DISASSEMBLER |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 RETURN_IF_SCHEDULED_EXCEPTION(); | 152 RETURN_IF_SCHEDULED_EXCEPTION(); |
152 return value; | 153 return value; |
153 } | 154 } |
154 | 155 |
155 // api style callbacks. | 156 // api style callbacks. |
156 if (structure->IsAccessorInfo()) { | 157 if (structure->IsAccessorInfo()) { |
157 AccessorInfo* data = AccessorInfo::cast(structure); | 158 AccessorInfo* data = AccessorInfo::cast(structure); |
158 Object* fun_obj = data->getter(); | 159 Object* fun_obj = data->getter(); |
159 v8::AccessorGetter call_fun = v8::ToCData<v8::AccessorGetter>(fun_obj); | 160 v8::AccessorGetter call_fun = v8::ToCData<v8::AccessorGetter>(fun_obj); |
160 HandleScope scope; | 161 HandleScope scope; |
161 Handle<JSObject> self(JSObject::cast(receiver)); | 162 JSObject* self = JSObject::cast(receiver); |
162 Handle<JSObject> holder_handle(JSObject::cast(holder)); | 163 JSObject* holder_handle = JSObject::cast(holder); |
163 Handle<String> key(name); | 164 Handle<String> key(name); |
164 Handle<Object> fun_data(data->data()); | 165 LOG(ApiNamedPropertyAccess("load", self, name)); |
165 LOG(ApiNamedPropertyAccess("load", *self, name)); | 166 CustomArguments args(data->data(), self, holder_handle); |
166 v8::AccessorInfo info(v8::Utils::ToLocal(self), | 167 v8::AccessorInfo info(args.end()); |
167 v8::Utils::ToLocal(fun_data), | |
168 v8::Utils::ToLocal(holder_handle)); | |
169 v8::Handle<v8::Value> result; | 168 v8::Handle<v8::Value> result; |
170 { | 169 { |
171 // Leaving JavaScript. | 170 // Leaving JavaScript. |
172 VMState state(EXTERNAL); | 171 VMState state(EXTERNAL); |
173 result = call_fun(v8::Utils::ToLocal(key), info); | 172 result = call_fun(v8::Utils::ToLocal(key), info); |
174 } | 173 } |
175 RETURN_IF_SCHEDULED_EXCEPTION(); | 174 RETURN_IF_SCHEDULED_EXCEPTION(); |
176 if (result.IsEmpty()) return Heap::undefined_value(); | 175 if (result.IsEmpty()) return Heap::undefined_value(); |
177 return *v8::Utils::OpenHandle(*result); | 176 return *v8::Utils::OpenHandle(*result); |
178 } | 177 } |
(...skipping 1352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1531 | 1530 |
1532 Object* JSObject::SetPropertyWithInterceptor(String* name, | 1531 Object* JSObject::SetPropertyWithInterceptor(String* name, |
1533 Object* value, | 1532 Object* value, |
1534 PropertyAttributes attributes) { | 1533 PropertyAttributes attributes) { |
1535 HandleScope scope; | 1534 HandleScope scope; |
1536 Handle<JSObject> this_handle(this); | 1535 Handle<JSObject> this_handle(this); |
1537 Handle<String> name_handle(name); | 1536 Handle<String> name_handle(name); |
1538 Handle<Object> value_handle(value); | 1537 Handle<Object> value_handle(value); |
1539 Handle<InterceptorInfo> interceptor(GetNamedInterceptor()); | 1538 Handle<InterceptorInfo> interceptor(GetNamedInterceptor()); |
1540 if (!interceptor->setter()->IsUndefined()) { | 1539 if (!interceptor->setter()->IsUndefined()) { |
1541 Handle<Object> data_handle(interceptor->data()); | |
1542 LOG(ApiNamedPropertyAccess("interceptor-named-set", this, name)); | 1540 LOG(ApiNamedPropertyAccess("interceptor-named-set", this, name)); |
1543 v8::AccessorInfo info(v8::Utils::ToLocal(this_handle), | 1541 CustomArguments args(interceptor->data(), this, this); |
1544 v8::Utils::ToLocal(data_handle), | 1542 v8::AccessorInfo info(args.end()); |
1545 v8::Utils::ToLocal(this_handle)); | |
1546 v8::NamedPropertySetter setter = | 1543 v8::NamedPropertySetter setter = |
1547 v8::ToCData<v8::NamedPropertySetter>(interceptor->setter()); | 1544 v8::ToCData<v8::NamedPropertySetter>(interceptor->setter()); |
1548 v8::Handle<v8::Value> result; | 1545 v8::Handle<v8::Value> result; |
1549 { | 1546 { |
1550 // Leaving JavaScript. | 1547 // Leaving JavaScript. |
1551 VMState state(EXTERNAL); | 1548 VMState state(EXTERNAL); |
1552 Handle<Object> value_unhole(value->IsTheHole() ? | 1549 Handle<Object> value_unhole(value->IsTheHole() ? |
1553 Heap::undefined_value() : | 1550 Heap::undefined_value() : |
1554 value); | 1551 value); |
1555 result = setter(v8::Utils::ToLocal(name_handle), | 1552 result = setter(v8::Utils::ToLocal(name_handle), |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1598 if (obj->IsFailure()) return obj; | 1595 if (obj->IsFailure()) return obj; |
1599 return *value_handle; | 1596 return *value_handle; |
1600 } | 1597 } |
1601 | 1598 |
1602 if (structure->IsAccessorInfo()) { | 1599 if (structure->IsAccessorInfo()) { |
1603 // api style callbacks | 1600 // api style callbacks |
1604 AccessorInfo* data = AccessorInfo::cast(structure); | 1601 AccessorInfo* data = AccessorInfo::cast(structure); |
1605 Object* call_obj = data->setter(); | 1602 Object* call_obj = data->setter(); |
1606 v8::AccessorSetter call_fun = v8::ToCData<v8::AccessorSetter>(call_obj); | 1603 v8::AccessorSetter call_fun = v8::ToCData<v8::AccessorSetter>(call_obj); |
1607 if (call_fun == NULL) return value; | 1604 if (call_fun == NULL) return value; |
1608 Handle<JSObject> self(this); | |
1609 Handle<JSObject> holder_handle(JSObject::cast(holder)); | |
1610 Handle<String> key(name); | 1605 Handle<String> key(name); |
1611 Handle<Object> fun_data(data->data()); | |
1612 LOG(ApiNamedPropertyAccess("store", this, name)); | 1606 LOG(ApiNamedPropertyAccess("store", this, name)); |
1613 v8::AccessorInfo info(v8::Utils::ToLocal(self), | 1607 CustomArguments args(data->data(), this, JSObject::cast(holder)); |
1614 v8::Utils::ToLocal(fun_data), | 1608 v8::AccessorInfo info(args.end()); |
1615 v8::Utils::ToLocal(holder_handle)); | |
1616 { | 1609 { |
1617 // Leaving JavaScript. | 1610 // Leaving JavaScript. |
1618 VMState state(EXTERNAL); | 1611 VMState state(EXTERNAL); |
1619 call_fun(v8::Utils::ToLocal(key), | 1612 call_fun(v8::Utils::ToLocal(key), |
1620 v8::Utils::ToLocal(value_handle), | 1613 v8::Utils::ToLocal(value_handle), |
1621 info); | 1614 info); |
1622 } | 1615 } |
1623 RETURN_IF_SCHEDULED_EXCEPTION(); | 1616 RETURN_IF_SCHEDULED_EXCEPTION(); |
1624 return *value_handle; | 1617 return *value_handle; |
1625 } | 1618 } |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2029 bool continue_search) { | 2022 bool continue_search) { |
2030 // Make sure that the top context does not change when doing | 2023 // Make sure that the top context does not change when doing |
2031 // callbacks or interceptor calls. | 2024 // callbacks or interceptor calls. |
2032 AssertNoContextChange ncc; | 2025 AssertNoContextChange ncc; |
2033 | 2026 |
2034 HandleScope scope; | 2027 HandleScope scope; |
2035 Handle<InterceptorInfo> interceptor(GetNamedInterceptor()); | 2028 Handle<InterceptorInfo> interceptor(GetNamedInterceptor()); |
2036 Handle<JSObject> receiver_handle(receiver); | 2029 Handle<JSObject> receiver_handle(receiver); |
2037 Handle<JSObject> holder_handle(this); | 2030 Handle<JSObject> holder_handle(this); |
2038 Handle<String> name_handle(name); | 2031 Handle<String> name_handle(name); |
2039 Handle<Object> data_handle(interceptor->data()); | 2032 CustomArguments args(interceptor->data(), receiver, this); |
2040 v8::AccessorInfo info(v8::Utils::ToLocal(receiver_handle), | 2033 v8::AccessorInfo info(args.end()); |
2041 v8::Utils::ToLocal(data_handle), | |
2042 v8::Utils::ToLocal(holder_handle)); | |
2043 if (!interceptor->query()->IsUndefined()) { | 2034 if (!interceptor->query()->IsUndefined()) { |
2044 v8::NamedPropertyQuery query = | 2035 v8::NamedPropertyQuery query = |
2045 v8::ToCData<v8::NamedPropertyQuery>(interceptor->query()); | 2036 v8::ToCData<v8::NamedPropertyQuery>(interceptor->query()); |
2046 LOG(ApiNamedPropertyAccess("interceptor-named-has", *holder_handle, name)); | 2037 LOG(ApiNamedPropertyAccess("interceptor-named-has", *holder_handle, name)); |
2047 v8::Handle<v8::Boolean> result; | 2038 v8::Handle<v8::Boolean> result; |
2048 { | 2039 { |
2049 // Leaving JavaScript. | 2040 // Leaving JavaScript. |
2050 VMState state(EXTERNAL); | 2041 VMState state(EXTERNAL); |
2051 result = query(v8::Utils::ToLocal(name_handle), info); | 2042 result = query(v8::Utils::ToLocal(name_handle), info); |
2052 } | 2043 } |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2300 | 2291 |
2301 | 2292 |
2302 Object* JSObject::DeletePropertyWithInterceptor(String* name) { | 2293 Object* JSObject::DeletePropertyWithInterceptor(String* name) { |
2303 HandleScope scope; | 2294 HandleScope scope; |
2304 Handle<InterceptorInfo> interceptor(GetNamedInterceptor()); | 2295 Handle<InterceptorInfo> interceptor(GetNamedInterceptor()); |
2305 Handle<String> name_handle(name); | 2296 Handle<String> name_handle(name); |
2306 Handle<JSObject> this_handle(this); | 2297 Handle<JSObject> this_handle(this); |
2307 if (!interceptor->deleter()->IsUndefined()) { | 2298 if (!interceptor->deleter()->IsUndefined()) { |
2308 v8::NamedPropertyDeleter deleter = | 2299 v8::NamedPropertyDeleter deleter = |
2309 v8::ToCData<v8::NamedPropertyDeleter>(interceptor->deleter()); | 2300 v8::ToCData<v8::NamedPropertyDeleter>(interceptor->deleter()); |
2310 Handle<Object> data_handle(interceptor->data()); | |
2311 LOG(ApiNamedPropertyAccess("interceptor-named-delete", *this_handle, name)); | 2301 LOG(ApiNamedPropertyAccess("interceptor-named-delete", *this_handle, name)); |
2312 v8::AccessorInfo info(v8::Utils::ToLocal(this_handle), | 2302 CustomArguments args(interceptor->data(), this, this); |
2313 v8::Utils::ToLocal(data_handle), | 2303 v8::AccessorInfo info(args.end()); |
2314 v8::Utils::ToLocal(this_handle)); | |
2315 v8::Handle<v8::Boolean> result; | 2304 v8::Handle<v8::Boolean> result; |
2316 { | 2305 { |
2317 // Leaving JavaScript. | 2306 // Leaving JavaScript. |
2318 VMState state(EXTERNAL); | 2307 VMState state(EXTERNAL); |
2319 result = deleter(v8::Utils::ToLocal(name_handle), info); | 2308 result = deleter(v8::Utils::ToLocal(name_handle), info); |
2320 } | 2309 } |
2321 RETURN_IF_SCHEDULED_EXCEPTION(); | 2310 RETURN_IF_SCHEDULED_EXCEPTION(); |
2322 if (!result.IsEmpty()) { | 2311 if (!result.IsEmpty()) { |
2323 ASSERT(result->IsBoolean()); | 2312 ASSERT(result->IsBoolean()); |
2324 return *v8::Utils::OpenHandle(*result); | 2313 return *v8::Utils::OpenHandle(*result); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2363 Object* JSObject::DeleteElementWithInterceptor(uint32_t index) { | 2352 Object* JSObject::DeleteElementWithInterceptor(uint32_t index) { |
2364 // Make sure that the top context does not change when doing | 2353 // Make sure that the top context does not change when doing |
2365 // callbacks or interceptor calls. | 2354 // callbacks or interceptor calls. |
2366 AssertNoContextChange ncc; | 2355 AssertNoContextChange ncc; |
2367 HandleScope scope; | 2356 HandleScope scope; |
2368 Handle<InterceptorInfo> interceptor(GetIndexedInterceptor()); | 2357 Handle<InterceptorInfo> interceptor(GetIndexedInterceptor()); |
2369 if (interceptor->deleter()->IsUndefined()) return Heap::false_value(); | 2358 if (interceptor->deleter()->IsUndefined()) return Heap::false_value(); |
2370 v8::IndexedPropertyDeleter deleter = | 2359 v8::IndexedPropertyDeleter deleter = |
2371 v8::ToCData<v8::IndexedPropertyDeleter>(interceptor->deleter()); | 2360 v8::ToCData<v8::IndexedPropertyDeleter>(interceptor->deleter()); |
2372 Handle<JSObject> this_handle(this); | 2361 Handle<JSObject> this_handle(this); |
2373 Handle<Object> data_handle(interceptor->data()); | |
2374 LOG(ApiIndexedPropertyAccess("interceptor-indexed-delete", this, index)); | 2362 LOG(ApiIndexedPropertyAccess("interceptor-indexed-delete", this, index)); |
2375 v8::AccessorInfo info(v8::Utils::ToLocal(this_handle), | 2363 CustomArguments args(interceptor->data(), this, this); |
2376 v8::Utils::ToLocal(data_handle), | 2364 v8::AccessorInfo info(args.end()); |
2377 v8::Utils::ToLocal(this_handle)); | |
2378 v8::Handle<v8::Boolean> result; | 2365 v8::Handle<v8::Boolean> result; |
2379 { | 2366 { |
2380 // Leaving JavaScript. | 2367 // Leaving JavaScript. |
2381 VMState state(EXTERNAL); | 2368 VMState state(EXTERNAL); |
2382 result = deleter(index, info); | 2369 result = deleter(index, info); |
2383 } | 2370 } |
2384 RETURN_IF_SCHEDULED_EXCEPTION(); | 2371 RETURN_IF_SCHEDULED_EXCEPTION(); |
2385 if (!result.IsEmpty()) { | 2372 if (!result.IsEmpty()) { |
2386 ASSERT(result->IsBoolean()); | 2373 ASSERT(result->IsBoolean()); |
2387 return *v8::Utils::OpenHandle(*result); | 2374 return *v8::Utils::OpenHandle(*result); |
(...skipping 1576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3964 } | 3951 } |
3965 default: | 3952 default: |
3966 break; | 3953 break; |
3967 } | 3954 } |
3968 | 3955 |
3969 UNREACHABLE(); | 3956 UNREACHABLE(); |
3970 return 0; | 3957 return 0; |
3971 } | 3958 } |
3972 | 3959 |
3973 | 3960 |
3974 FlatStringReader* FlatStringReader::top_ = NULL; | 3961 Relocatable* Relocatable::top_ = NULL; |
| 3962 |
| 3963 |
| 3964 void Relocatable::PostGarbageCollectionProcessing() { |
| 3965 Relocatable* current = top_; |
| 3966 while (current != NULL) { |
| 3967 current->PostGarbageCollection(); |
| 3968 current = current->prev_; |
| 3969 } |
| 3970 } |
| 3971 |
| 3972 |
| 3973 // Reserve space for statics needing saving and restoring. |
| 3974 int Relocatable::ArchiveSpacePerThread() { |
| 3975 return sizeof(top_); |
| 3976 } |
| 3977 |
| 3978 |
| 3979 // Archive statics that are thread local. |
| 3980 char* Relocatable::ArchiveState(char* to) { |
| 3981 *reinterpret_cast<Relocatable**>(to) = top_; |
| 3982 top_ = NULL; |
| 3983 return to + ArchiveSpacePerThread(); |
| 3984 } |
| 3985 |
| 3986 |
| 3987 // Restore statics that are thread local. |
| 3988 char* Relocatable::RestoreState(char* from) { |
| 3989 top_ = *reinterpret_cast<Relocatable**>(from); |
| 3990 return from + ArchiveSpacePerThread(); |
| 3991 } |
| 3992 |
| 3993 |
| 3994 char* Relocatable::Iterate(ObjectVisitor* v, char* thread_storage) { |
| 3995 Relocatable* top = *reinterpret_cast<Relocatable**>(thread_storage); |
| 3996 Iterate(v, top); |
| 3997 return thread_storage + ArchiveSpacePerThread(); |
| 3998 } |
| 3999 |
| 4000 |
| 4001 void Relocatable::Iterate(ObjectVisitor* v) { |
| 4002 Iterate(v, top_); |
| 4003 } |
| 4004 |
| 4005 |
| 4006 void Relocatable::Iterate(ObjectVisitor* v, Relocatable* top) { |
| 4007 Relocatable* current = top; |
| 4008 while (current != NULL) { |
| 4009 current->IterateInstance(v); |
| 4010 current = current->prev_; |
| 4011 } |
| 4012 } |
3975 | 4013 |
3976 | 4014 |
3977 FlatStringReader::FlatStringReader(Handle<String> str) | 4015 FlatStringReader::FlatStringReader(Handle<String> str) |
3978 : str_(str.location()), | 4016 : str_(str.location()), |
3979 length_(str->length()), | 4017 length_(str->length()) { |
3980 prev_(top_) { | 4018 PostGarbageCollection(); |
3981 top_ = this; | |
3982 RefreshState(); | |
3983 } | 4019 } |
3984 | 4020 |
3985 | 4021 |
3986 FlatStringReader::FlatStringReader(Vector<const char> input) | 4022 FlatStringReader::FlatStringReader(Vector<const char> input) |
3987 : str_(NULL), | 4023 : str_(0), |
3988 is_ascii_(true), | 4024 is_ascii_(true), |
3989 length_(input.length()), | 4025 length_(input.length()), |
3990 start_(input.start()), | 4026 start_(input.start()) { } |
3991 prev_(top_) { | |
3992 top_ = this; | |
3993 } | |
3994 | 4027 |
3995 | 4028 |
3996 FlatStringReader::~FlatStringReader() { | 4029 void FlatStringReader::PostGarbageCollection() { |
3997 ASSERT_EQ(top_, this); | |
3998 top_ = prev_; | |
3999 } | |
4000 | |
4001 | |
4002 void FlatStringReader::RefreshState() { | |
4003 if (str_ == NULL) return; | 4030 if (str_ == NULL) return; |
4004 Handle<String> str(str_); | 4031 Handle<String> str(str_); |
4005 ASSERT(str->IsFlat()); | 4032 ASSERT(str->IsFlat()); |
4006 is_ascii_ = str->IsAsciiRepresentation(); | 4033 is_ascii_ = str->IsAsciiRepresentation(); |
4007 if (is_ascii_) { | 4034 if (is_ascii_) { |
4008 start_ = str->ToAsciiVector().start(); | 4035 start_ = str->ToAsciiVector().start(); |
4009 } else { | 4036 } else { |
4010 start_ = str->ToUC16Vector().start(); | 4037 start_ = str->ToUC16Vector().start(); |
4011 } | 4038 } |
4012 } | 4039 } |
4013 | 4040 |
4014 | 4041 |
4015 void FlatStringReader::PostGarbageCollectionProcessing() { | |
4016 FlatStringReader* current = top_; | |
4017 while (current != NULL) { | |
4018 current->RefreshState(); | |
4019 current = current->prev_; | |
4020 } | |
4021 } | |
4022 | |
4023 | |
4024 void StringInputBuffer::Seek(unsigned pos) { | 4042 void StringInputBuffer::Seek(unsigned pos) { |
4025 Reset(pos, input_); | 4043 Reset(pos, input_); |
4026 } | 4044 } |
4027 | 4045 |
4028 | 4046 |
4029 void SafeStringInputBuffer::Seek(unsigned pos) { | 4047 void SafeStringInputBuffer::Seek(unsigned pos) { |
4030 Reset(pos, input_); | 4048 Reset(pos, input_); |
4031 } | 4049 } |
4032 | 4050 |
4033 | 4051 |
(...skipping 1388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5422 | 5440 |
5423 | 5441 |
5424 bool JSObject::HasElementWithInterceptor(JSObject* receiver, uint32_t index) { | 5442 bool JSObject::HasElementWithInterceptor(JSObject* receiver, uint32_t index) { |
5425 // Make sure that the top context does not change when doing | 5443 // Make sure that the top context does not change when doing |
5426 // callbacks or interceptor calls. | 5444 // callbacks or interceptor calls. |
5427 AssertNoContextChange ncc; | 5445 AssertNoContextChange ncc; |
5428 HandleScope scope; | 5446 HandleScope scope; |
5429 Handle<InterceptorInfo> interceptor(GetIndexedInterceptor()); | 5447 Handle<InterceptorInfo> interceptor(GetIndexedInterceptor()); |
5430 Handle<JSObject> receiver_handle(receiver); | 5448 Handle<JSObject> receiver_handle(receiver); |
5431 Handle<JSObject> holder_handle(this); | 5449 Handle<JSObject> holder_handle(this); |
5432 Handle<Object> data_handle(interceptor->data()); | 5450 CustomArguments args(interceptor->data(), receiver, this); |
5433 v8::AccessorInfo info(v8::Utils::ToLocal(receiver_handle), | 5451 v8::AccessorInfo info(args.end()); |
5434 v8::Utils::ToLocal(data_handle), | |
5435 v8::Utils::ToLocal(holder_handle)); | |
5436 if (!interceptor->query()->IsUndefined()) { | 5452 if (!interceptor->query()->IsUndefined()) { |
5437 v8::IndexedPropertyQuery query = | 5453 v8::IndexedPropertyQuery query = |
5438 v8::ToCData<v8::IndexedPropertyQuery>(interceptor->query()); | 5454 v8::ToCData<v8::IndexedPropertyQuery>(interceptor->query()); |
5439 LOG(ApiIndexedPropertyAccess("interceptor-indexed-has", this, index)); | 5455 LOG(ApiIndexedPropertyAccess("interceptor-indexed-has", this, index)); |
5440 v8::Handle<v8::Boolean> result; | 5456 v8::Handle<v8::Boolean> result; |
5441 { | 5457 { |
5442 // Leaving JavaScript. | 5458 // Leaving JavaScript. |
5443 VMState state(EXTERNAL); | 5459 VMState state(EXTERNAL); |
5444 result = query(index, info); | 5460 result = query(index, info); |
5445 } | 5461 } |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5557 // Make sure that the top context does not change when doing | 5573 // Make sure that the top context does not change when doing |
5558 // callbacks or interceptor calls. | 5574 // callbacks or interceptor calls. |
5559 AssertNoContextChange ncc; | 5575 AssertNoContextChange ncc; |
5560 HandleScope scope; | 5576 HandleScope scope; |
5561 Handle<InterceptorInfo> interceptor(GetIndexedInterceptor()); | 5577 Handle<InterceptorInfo> interceptor(GetIndexedInterceptor()); |
5562 Handle<JSObject> this_handle(this); | 5578 Handle<JSObject> this_handle(this); |
5563 Handle<Object> value_handle(value); | 5579 Handle<Object> value_handle(value); |
5564 if (!interceptor->setter()->IsUndefined()) { | 5580 if (!interceptor->setter()->IsUndefined()) { |
5565 v8::IndexedPropertySetter setter = | 5581 v8::IndexedPropertySetter setter = |
5566 v8::ToCData<v8::IndexedPropertySetter>(interceptor->setter()); | 5582 v8::ToCData<v8::IndexedPropertySetter>(interceptor->setter()); |
5567 Handle<Object> data_handle(interceptor->data()); | |
5568 LOG(ApiIndexedPropertyAccess("interceptor-indexed-set", this, index)); | 5583 LOG(ApiIndexedPropertyAccess("interceptor-indexed-set", this, index)); |
5569 v8::AccessorInfo info(v8::Utils::ToLocal(this_handle), | 5584 CustomArguments args(interceptor->data(), this, this); |
5570 v8::Utils::ToLocal(data_handle), | 5585 v8::AccessorInfo info(args.end()); |
5571 v8::Utils::ToLocal(this_handle)); | |
5572 v8::Handle<v8::Value> result; | 5586 v8::Handle<v8::Value> result; |
5573 { | 5587 { |
5574 // Leaving JavaScript. | 5588 // Leaving JavaScript. |
5575 VMState state(EXTERNAL); | 5589 VMState state(EXTERNAL); |
5576 result = setter(index, v8::Utils::ToLocal(value_handle), info); | 5590 result = setter(index, v8::Utils::ToLocal(value_handle), info); |
5577 } | 5591 } |
5578 RETURN_IF_SCHEDULED_EXCEPTION(); | 5592 RETURN_IF_SCHEDULED_EXCEPTION(); |
5579 if (!result.IsEmpty()) return *value_handle; | 5593 if (!result.IsEmpty()) return *value_handle; |
5580 } | 5594 } |
5581 Object* raw_result = | 5595 Object* raw_result = |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5829 uint32_t index) { | 5843 uint32_t index) { |
5830 // Make sure that the top context does not change when doing | 5844 // Make sure that the top context does not change when doing |
5831 // callbacks or interceptor calls. | 5845 // callbacks or interceptor calls. |
5832 AssertNoContextChange ncc; | 5846 AssertNoContextChange ncc; |
5833 HandleScope scope; | 5847 HandleScope scope; |
5834 Handle<InterceptorInfo> interceptor(GetIndexedInterceptor()); | 5848 Handle<InterceptorInfo> interceptor(GetIndexedInterceptor()); |
5835 Handle<JSObject> this_handle(receiver); | 5849 Handle<JSObject> this_handle(receiver); |
5836 Handle<JSObject> holder_handle(this); | 5850 Handle<JSObject> holder_handle(this); |
5837 | 5851 |
5838 if (!interceptor->getter()->IsUndefined()) { | 5852 if (!interceptor->getter()->IsUndefined()) { |
5839 Handle<Object> data_handle(interceptor->data()); | |
5840 v8::IndexedPropertyGetter getter = | 5853 v8::IndexedPropertyGetter getter = |
5841 v8::ToCData<v8::IndexedPropertyGetter>(interceptor->getter()); | 5854 v8::ToCData<v8::IndexedPropertyGetter>(interceptor->getter()); |
5842 LOG(ApiIndexedPropertyAccess("interceptor-indexed-get", this, index)); | 5855 LOG(ApiIndexedPropertyAccess("interceptor-indexed-get", this, index)); |
5843 v8::AccessorInfo info(v8::Utils::ToLocal(this_handle), | 5856 CustomArguments args(interceptor->data(), receiver, this); |
5844 v8::Utils::ToLocal(data_handle), | 5857 v8::AccessorInfo info(args.end()); |
5845 v8::Utils::ToLocal(holder_handle)); | |
5846 v8::Handle<v8::Value> result; | 5858 v8::Handle<v8::Value> result; |
5847 { | 5859 { |
5848 // Leaving JavaScript. | 5860 // Leaving JavaScript. |
5849 VMState state(EXTERNAL); | 5861 VMState state(EXTERNAL); |
5850 result = getter(index, info); | 5862 result = getter(index, info); |
5851 } | 5863 } |
5852 RETURN_IF_SCHEDULED_EXCEPTION(); | 5864 RETURN_IF_SCHEDULED_EXCEPTION(); |
5853 if (!result.IsEmpty()) return *v8::Utils::OpenHandle(*result); | 5865 if (!result.IsEmpty()) return *v8::Utils::OpenHandle(*result); |
5854 } | 5866 } |
5855 | 5867 |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6067 | 6079 |
6068 Object* JSObject::GetPropertyWithInterceptor( | 6080 Object* JSObject::GetPropertyWithInterceptor( |
6069 JSObject* receiver, | 6081 JSObject* receiver, |
6070 String* name, | 6082 String* name, |
6071 PropertyAttributes* attributes) { | 6083 PropertyAttributes* attributes) { |
6072 InterceptorInfo* interceptor = GetNamedInterceptor(); | 6084 InterceptorInfo* interceptor = GetNamedInterceptor(); |
6073 HandleScope scope; | 6085 HandleScope scope; |
6074 Handle<JSObject> receiver_handle(receiver); | 6086 Handle<JSObject> receiver_handle(receiver); |
6075 Handle<JSObject> holder_handle(this); | 6087 Handle<JSObject> holder_handle(this); |
6076 Handle<String> name_handle(name); | 6088 Handle<String> name_handle(name); |
6077 Handle<Object> data_handle(interceptor->data()); | |
6078 | 6089 |
6079 if (!interceptor->getter()->IsUndefined()) { | 6090 if (!interceptor->getter()->IsUndefined()) { |
6080 v8::NamedPropertyGetter getter = | 6091 v8::NamedPropertyGetter getter = |
6081 v8::ToCData<v8::NamedPropertyGetter>(interceptor->getter()); | 6092 v8::ToCData<v8::NamedPropertyGetter>(interceptor->getter()); |
6082 LOG(ApiNamedPropertyAccess("interceptor-named-get", *holder_handle, name)); | 6093 LOG(ApiNamedPropertyAccess("interceptor-named-get", *holder_handle, name)); |
6083 v8::AccessorInfo info(v8::Utils::ToLocal(receiver_handle), | 6094 CustomArguments args(interceptor->data(), receiver, this); |
6084 v8::Utils::ToLocal(data_handle), | 6095 v8::AccessorInfo info(args.end()); |
6085 v8::Utils::ToLocal(holder_handle)); | |
6086 v8::Handle<v8::Value> result; | 6096 v8::Handle<v8::Value> result; |
6087 { | 6097 { |
6088 // Leaving JavaScript. | 6098 // Leaving JavaScript. |
6089 VMState state(EXTERNAL); | 6099 VMState state(EXTERNAL); |
6090 result = getter(v8::Utils::ToLocal(name_handle), info); | 6100 result = getter(v8::Utils::ToLocal(name_handle), info); |
6091 } | 6101 } |
6092 RETURN_IF_SCHEDULED_EXCEPTION(); | 6102 RETURN_IF_SCHEDULED_EXCEPTION(); |
6093 if (!result.IsEmpty()) { | 6103 if (!result.IsEmpty()) { |
6094 *attributes = NONE; | 6104 *attributes = NONE; |
6095 return *v8::Utils::OpenHandle(*result); | 6105 return *v8::Utils::OpenHandle(*result); |
(...skipping 1867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7963 if (break_point_objects()->IsUndefined()) return 0; | 7973 if (break_point_objects()->IsUndefined()) return 0; |
7964 // Single beak point. | 7974 // Single beak point. |
7965 if (!break_point_objects()->IsFixedArray()) return 1; | 7975 if (!break_point_objects()->IsFixedArray()) return 1; |
7966 // Multiple break points. | 7976 // Multiple break points. |
7967 return FixedArray::cast(break_point_objects())->length(); | 7977 return FixedArray::cast(break_point_objects())->length(); |
7968 } | 7978 } |
7969 #endif | 7979 #endif |
7970 | 7980 |
7971 | 7981 |
7972 } } // namespace v8::internal | 7982 } } // namespace v8::internal |
OLD | NEW |