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

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: Created 9 years, 11 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/messages.cc » ('j') | src/messages.cc » ('J')
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 1390 matching lines...) Expand 10 before | Expand all | Expand 10 after
1401 v8::Handle<v8::Value> v8::TryCatch::ReThrow() { 1401 v8::Handle<v8::Value> v8::TryCatch::ReThrow() {
1402 if (!HasCaught()) return v8::Local<v8::Value>(); 1402 if (!HasCaught()) return v8::Local<v8::Value>();
1403 rethrow_ = true; 1403 rethrow_ = true;
1404 return v8::Undefined(); 1404 return v8::Undefined();
1405 } 1405 }
1406 1406
1407 1407
1408 v8::Local<Value> v8::TryCatch::Exception() const { 1408 v8::Local<Value> v8::TryCatch::Exception() const {
1409 if (HasCaught()) { 1409 if (HasCaught()) {
1410 // Check for out of memory exception. 1410 // Check for out of memory exception.
1411 i::Object* exception = reinterpret_cast<i::Object*>(exception_); 1411 i::Object* exception = reinterpret_cast<i::Object*>(exception_);
Vitaly Repeshko 2011/01/28 14:03:33 Hmm, how is this supposed to work with a raw point
antonm 2011/01/28 14:43:18 Take a look at Top::Iterate---it turns exception_
1412 return v8::Utils::ToLocal(i::Handle<i::Object>(exception)); 1412 return v8::Utils::ToLocal(i::Handle<i::Object>(exception));
1413 } else { 1413 } else {
1414 return v8::Local<Value>(); 1414 return v8::Local<Value>();
1415 } 1415 }
1416 } 1416 }
1417 1417
1418 1418
1419 v8::Local<Value> v8::TryCatch::StackTrace() const { 1419 v8::Local<Value> v8::TryCatch::StackTrace() const {
1420 if (HasCaught()) { 1420 if (HasCaught()) {
1421 i::Object* raw_obj = reinterpret_cast<i::Object*>(exception_); 1421 i::Object* raw_obj = reinterpret_cast<i::Object*>(exception_);
(...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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);
2582
2583 // If the property being looked up is a callback, it can throw
2584 // an exception.
2585 has_pending_exception = value->IsFailure();
Mads Ager (chromium) 2011/01/28 11:39:18 Should you test for value->IsException instead and
antonm 2011/01/28 13:37:25 I can, but not sure if it's a good idea. Plus tec
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
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
OLDNEW
« no previous file with comments | « no previous file | src/messages.cc » ('j') | src/messages.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698