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

Side by Side Diff: src/api.cc

Issue 6397011: Make exception thrown via v8 public API propagate to v8::TryCatch as JS thrown exceptions do. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressing Vitaly's comments Created 9 years, 10 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/handles.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 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 2365 matching lines...) Expand 10 before | Expand all | Expand 10 after
2376 i::Handle<i::Object> result = i::GetPrototype(self); 2376 i::Handle<i::Object> result = i::GetPrototype(self);
2377 return Utils::ToLocal(result); 2377 return Utils::ToLocal(result);
2378 } 2378 }
2379 2379
2380 2380
2381 bool v8::Object::SetPrototype(Handle<Value> value) { 2381 bool v8::Object::SetPrototype(Handle<Value> value) {
2382 ON_BAILOUT("v8::Object::SetPrototype()", return false); 2382 ON_BAILOUT("v8::Object::SetPrototype()", return false);
2383 ENTER_V8; 2383 ENTER_V8;
2384 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2384 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2385 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); 2385 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
2386 // We do not allow exceptions thrown while setting the prototype
2387 // propagate outside.
2388 TryCatch try_catch;
2386 EXCEPTION_PREAMBLE(); 2389 EXCEPTION_PREAMBLE();
2387 i::Handle<i::Object> result = i::SetPrototype(self, value_obj); 2390 i::Handle<i::Object> result = i::SetPrototype(self, value_obj);
2388 has_pending_exception = result.is_null(); 2391 has_pending_exception = result.is_null();
2389 EXCEPTION_BAILOUT_CHECK(false); 2392 EXCEPTION_BAILOUT_CHECK(false);
2390 return true; 2393 return true;
2391 } 2394 }
2392 2395
2393 2396
2394 Local<Object> v8::Object::FindInstanceInPrototypeChain( 2397 Local<Object> v8::Object::FindInstanceInPrototypeChain(
2395 v8::Handle<FunctionTemplate> tmpl) { 2398 v8::Handle<FunctionTemplate> tmpl) {
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
2562 return Utils::OpenHandle(this)->HasNamedInterceptor(); 2565 return Utils::OpenHandle(this)->HasNamedInterceptor();
2563 } 2566 }
2564 2567
2565 2568
2566 bool v8::Object::HasIndexedLookupInterceptor() { 2569 bool v8::Object::HasIndexedLookupInterceptor() {
2567 ON_BAILOUT("v8::Object::HasIndexedLookupInterceptor()", return false); 2570 ON_BAILOUT("v8::Object::HasIndexedLookupInterceptor()", return false);
2568 return Utils::OpenHandle(this)->HasIndexedInterceptor(); 2571 return Utils::OpenHandle(this)->HasIndexedInterceptor();
2569 } 2572 }
2570 2573
2571 2574
2575 static Local<Value> GetPropertyByLookup(i::Handle<i::JSObject> receiver,
2576 i::Handle<i::String> name,
2577 i::LookupResult* lookup) {
2578 if (!lookup->IsProperty()) {
2579 // No real property was found.
2580 return Local<Value>();
2581 }
2582
2583 // If the property being looked up is a callback, it can throw
2584 // an exception.
2585 EXCEPTION_PREAMBLE();
2586 i::Handle<i::Object> result = i::GetProperty(receiver, name, lookup);
2587 has_pending_exception = result.is_null();
2588 EXCEPTION_BAILOUT_CHECK(Local<Value>());
2589
2590 return Utils::ToLocal(result);
2591 }
2592
2593
2572 Local<Value> v8::Object::GetRealNamedPropertyInPrototypeChain( 2594 Local<Value> v8::Object::GetRealNamedPropertyInPrototypeChain(
2573 Handle<String> key) { 2595 Handle<String> key) {
2574 ON_BAILOUT("v8::Object::GetRealNamedPropertyInPrototypeChain()", 2596 ON_BAILOUT("v8::Object::GetRealNamedPropertyInPrototypeChain()",
2575 return Local<Value>()); 2597 return Local<Value>());
2576 ENTER_V8; 2598 ENTER_V8;
2577 i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this); 2599 i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this);
2578 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); 2600 i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
2579 i::LookupResult lookup; 2601 i::LookupResult lookup;
2580 self_obj->LookupRealNamedPropertyInPrototypes(*key_obj, &lookup); 2602 self_obj->LookupRealNamedPropertyInPrototypes(*key_obj, &lookup);
2581 if (lookup.IsProperty()) { 2603 return GetPropertyByLookup(self_obj, key_obj, &lookup);
2582 PropertyAttributes attributes;
2583 i::Object* property =
2584 self_obj->GetProperty(*self_obj,
2585 &lookup,
2586 *key_obj,
2587 &attributes)->ToObjectUnchecked();
2588 i::Handle<i::Object> result(property);
2589 return Utils::ToLocal(result);
2590 }
2591 return Local<Value>(); // No real property was found in prototype chain.
2592 } 2604 }
2593 2605
2594 2606
2595 Local<Value> v8::Object::GetRealNamedProperty(Handle<String> key) { 2607 Local<Value> v8::Object::GetRealNamedProperty(Handle<String> key) {
2596 ON_BAILOUT("v8::Object::GetRealNamedProperty()", return Local<Value>()); 2608 ON_BAILOUT("v8::Object::GetRealNamedProperty()", return Local<Value>());
2597 ENTER_V8; 2609 ENTER_V8;
2598 i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this); 2610 i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this);
2599 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); 2611 i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
2600 i::LookupResult lookup; 2612 i::LookupResult lookup;
2601 self_obj->LookupRealNamedProperty(*key_obj, &lookup); 2613 self_obj->LookupRealNamedProperty(*key_obj, &lookup);
2602 if (lookup.IsProperty()) { 2614 return GetPropertyByLookup(self_obj, key_obj, &lookup);
2603 PropertyAttributes attributes;
2604 i::Object* property =
2605 self_obj->GetProperty(*self_obj,
2606 &lookup,
2607 *key_obj,
2608 &attributes)->ToObjectUnchecked();
2609 i::Handle<i::Object> result(property);
2610 return Utils::ToLocal(result);
2611 }
2612 return Local<Value>(); // No real property was found in prototype chain.
2613 } 2615 }
2614 2616
2615 2617
2616 // Turns on access checks by copying the map and setting the check flag. 2618 // Turns on access checks by copying the map and setting the check flag.
2617 // Because the object gets a new map, existing inline cache caching 2619 // Because the object gets a new map, existing inline cache caching
2618 // the old map of this object will fail. 2620 // the old map of this object will fail.
2619 void v8::Object::TurnOnAccessCheck() { 2621 void v8::Object::TurnOnAccessCheck() {
2620 ON_BAILOUT("v8::Object::TurnOnAccessCheck()", return); 2622 ON_BAILOUT("v8::Object::TurnOnAccessCheck()", return);
2621 ENTER_V8; 2623 ENTER_V8;
2622 HandleScope scope; 2624 HandleScope scope;
(...skipping 2539 matching lines...) Expand 10 before | Expand all | Expand 10 after
5162 5164
5163 5165
5164 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { 5166 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) {
5165 HandleScopeImplementer* thread_local = 5167 HandleScopeImplementer* thread_local =
5166 reinterpret_cast<HandleScopeImplementer*>(storage); 5168 reinterpret_cast<HandleScopeImplementer*>(storage);
5167 thread_local->IterateThis(v); 5169 thread_local->IterateThis(v);
5168 return storage + ArchiveSpacePerThread(); 5170 return storage + ArchiveSpacePerThread();
5169 } 5171 }
5170 5172
5171 } } // namespace v8::internal 5173 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/handles.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698