OLD | NEW |
---|---|
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 2359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2370 i::Handle<i::Object> result = i::GetPrototype(self); | 2370 i::Handle<i::Object> result = i::GetPrototype(self); |
2371 return Utils::ToLocal(result); | 2371 return Utils::ToLocal(result); |
2372 } | 2372 } |
2373 | 2373 |
2374 | 2374 |
2375 bool v8::Object::SetPrototype(Handle<Value> value) { | 2375 bool v8::Object::SetPrototype(Handle<Value> value) { |
2376 ON_BAILOUT("v8::Object::SetPrototype()", return false); | 2376 ON_BAILOUT("v8::Object::SetPrototype()", return false); |
2377 ENTER_V8; | 2377 ENTER_V8; |
2378 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 2378 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
2379 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); | 2379 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); |
2380 // We do not allow exceptions thrown while setting the prototype | |
2381 // propagate outside. | |
2382 TryCatch try_catch; | |
2380 EXCEPTION_PREAMBLE(); | 2383 EXCEPTION_PREAMBLE(); |
2381 i::Handle<i::Object> result = i::SetPrototype(self, value_obj); | 2384 i::Handle<i::Object> result = i::SetPrototype(self, value_obj); |
2382 has_pending_exception = result.is_null(); | 2385 has_pending_exception = result.is_null(); |
2383 EXCEPTION_BAILOUT_CHECK(false); | 2386 EXCEPTION_BAILOUT_CHECK(false); |
2384 return true; | 2387 return true; |
2385 } | 2388 } |
2386 | 2389 |
2387 | 2390 |
2388 Local<Object> v8::Object::FindInstanceInPrototypeChain( | 2391 Local<Object> v8::Object::FindInstanceInPrototypeChain( |
2389 v8::Handle<FunctionTemplate> tmpl) { | 2392 v8::Handle<FunctionTemplate> tmpl) { |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2556 return Utils::OpenHandle(this)->HasNamedInterceptor(); | 2559 return Utils::OpenHandle(this)->HasNamedInterceptor(); |
2557 } | 2560 } |
2558 | 2561 |
2559 | 2562 |
2560 bool v8::Object::HasIndexedLookupInterceptor() { | 2563 bool v8::Object::HasIndexedLookupInterceptor() { |
2561 ON_BAILOUT("v8::Object::HasIndexedLookupInterceptor()", return false); | 2564 ON_BAILOUT("v8::Object::HasIndexedLookupInterceptor()", return false); |
2562 return Utils::OpenHandle(this)->HasIndexedInterceptor(); | 2565 return Utils::OpenHandle(this)->HasIndexedInterceptor(); |
2563 } | 2566 } |
2564 | 2567 |
2565 | 2568 |
2569 static Local<Value> GetPropertyByLookup(i::Handle<i::JSObject> receiver, | |
2570 i::Handle<i::String> name, | |
2571 i::LookupResult* lookup) { | |
2572 if (!lookup->IsProperty()) { | |
2573 // No real property was found. | |
2574 return Local<Value>(); | |
2575 } | |
2576 | |
2577 EXCEPTION_PREAMBLE(); | |
2578 | |
2579 PropertyAttributes attributes; | |
2580 i::MaybeObject* value = | |
2581 receiver->GetProperty(*receiver, lookup, *name, &attributes); | |
Vitaly Repeshko
2011/02/01 19:07:17
Wrap this in CALL_HEAP_FUNCTION?
antonm
2011/02/01 20:14:39
Done.
| |
2582 | |
2583 // If the property being looked up is a callback, it can throw | |
2584 // an exception. | |
2585 has_pending_exception = value->IsFailure(); | |
2586 EXCEPTION_BAILOUT_CHECK(Local<Value>()); | |
2587 | |
2588 i::Handle<i::Object> result(value->ToObjectUnchecked()); | |
2589 return Utils::ToLocal(result); | |
2590 } | |
2591 | |
2592 | |
2566 Local<Value> v8::Object::GetRealNamedPropertyInPrototypeChain( | 2593 Local<Value> v8::Object::GetRealNamedPropertyInPrototypeChain( |
2567 Handle<String> key) { | 2594 Handle<String> key) { |
2568 ON_BAILOUT("v8::Object::GetRealNamedPropertyInPrototypeChain()", | 2595 ON_BAILOUT("v8::Object::GetRealNamedPropertyInPrototypeChain()", |
2569 return Local<Value>()); | 2596 return Local<Value>()); |
2570 ENTER_V8; | 2597 ENTER_V8; |
2571 i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this); | 2598 i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this); |
2572 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); | 2599 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); |
2573 i::LookupResult lookup; | 2600 i::LookupResult lookup; |
2574 self_obj->LookupRealNamedPropertyInPrototypes(*key_obj, &lookup); | 2601 self_obj->LookupRealNamedPropertyInPrototypes(*key_obj, &lookup); |
2575 if (lookup.IsProperty()) { | 2602 return GetPropertyByLookup(self_obj, key_obj, &lookup); |
2576 PropertyAttributes attributes; | |
2577 i::Object* property = | |
2578 self_obj->GetProperty(*self_obj, | |
2579 &lookup, | |
2580 *key_obj, | |
2581 &attributes)->ToObjectUnchecked(); | |
2582 i::Handle<i::Object> result(property); | |
2583 return Utils::ToLocal(result); | |
2584 } | |
2585 return Local<Value>(); // No real property was found in prototype chain. | |
2586 } | 2603 } |
2587 | 2604 |
2588 | 2605 |
2589 Local<Value> v8::Object::GetRealNamedProperty(Handle<String> key) { | 2606 Local<Value> v8::Object::GetRealNamedProperty(Handle<String> key) { |
2590 ON_BAILOUT("v8::Object::GetRealNamedProperty()", return Local<Value>()); | 2607 ON_BAILOUT("v8::Object::GetRealNamedProperty()", return Local<Value>()); |
2591 ENTER_V8; | 2608 ENTER_V8; |
2592 i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this); | 2609 i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this); |
2593 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); | 2610 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); |
2594 i::LookupResult lookup; | 2611 i::LookupResult lookup; |
2595 self_obj->LookupRealNamedProperty(*key_obj, &lookup); | 2612 self_obj->LookupRealNamedProperty(*key_obj, &lookup); |
2596 if (lookup.IsProperty()) { | 2613 return GetPropertyByLookup(self_obj, key_obj, &lookup); |
2597 PropertyAttributes attributes; | |
2598 i::Object* property = | |
2599 self_obj->GetProperty(*self_obj, | |
2600 &lookup, | |
2601 *key_obj, | |
2602 &attributes)->ToObjectUnchecked(); | |
2603 i::Handle<i::Object> result(property); | |
2604 return Utils::ToLocal(result); | |
2605 } | |
2606 return Local<Value>(); // No real property was found in prototype chain. | |
2607 } | 2614 } |
2608 | 2615 |
2609 | 2616 |
2610 // Turns on access checks by copying the map and setting the check flag. | 2617 // Turns on access checks by copying the map and setting the check flag. |
2611 // Because the object gets a new map, existing inline cache caching | 2618 // Because the object gets a new map, existing inline cache caching |
2612 // the old map of this object will fail. | 2619 // the old map of this object will fail. |
2613 void v8::Object::TurnOnAccessCheck() { | 2620 void v8::Object::TurnOnAccessCheck() { |
2614 ON_BAILOUT("v8::Object::TurnOnAccessCheck()", return); | 2621 ON_BAILOUT("v8::Object::TurnOnAccessCheck()", return); |
2615 ENTER_V8; | 2622 ENTER_V8; |
2616 HandleScope scope; | 2623 HandleScope scope; |
(...skipping 2539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5156 | 5163 |
5157 | 5164 |
5158 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { | 5165 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { |
5159 HandleScopeImplementer* thread_local = | 5166 HandleScopeImplementer* thread_local = |
5160 reinterpret_cast<HandleScopeImplementer*>(storage); | 5167 reinterpret_cast<HandleScopeImplementer*>(storage); |
5161 thread_local->IterateThis(v); | 5168 thread_local->IterateThis(v); |
5162 return storage + ArchiveSpacePerThread(); | 5169 return storage + ArchiveSpacePerThread(); |
5163 } | 5170 } |
5164 | 5171 |
5165 } } // namespace v8::internal | 5172 } } // namespace v8::internal |
OLD | NEW |