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

Side by Side Diff: src/objects.cc

Issue 7623013: Test (and fix) all exception paths that can occur with proxies. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 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 | test/mjsunit/harmony/proxies.js » ('j') | test/mjsunit/harmony/proxies.js » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 Object* handler_raw) { 231 Object* handler_raw) {
232 Isolate* isolate = name_raw->GetIsolate(); 232 Isolate* isolate = name_raw->GetIsolate();
233 HandleScope scope(isolate); 233 HandleScope scope(isolate);
234 Handle<Object> receiver(receiver_raw); 234 Handle<Object> receiver(receiver_raw);
235 Handle<Object> name(name_raw); 235 Handle<Object> name(name_raw);
236 Handle<Object> handler(handler_raw); 236 Handle<Object> handler(handler_raw);
237 237
238 // Extract trap function. 238 // Extract trap function.
239 Handle<String> trap_name = isolate->factory()->LookupAsciiSymbol("get"); 239 Handle<String> trap_name = isolate->factory()->LookupAsciiSymbol("get");
240 Handle<Object> trap(v8::internal::GetProperty(handler, trap_name)); 240 Handle<Object> trap(v8::internal::GetProperty(handler, trap_name));
241 if (isolate->has_pending_exception()) return Failure::Exception();
241 if (trap->IsUndefined()) { 242 if (trap->IsUndefined()) {
242 // Get the derived `get' property. 243 // Get the derived `get' property.
243 trap = isolate->derived_get_trap(); 244 trap = isolate->derived_get_trap();
244 } 245 }
245 246
246 // Call trap function. 247 // Call trap function.
247 Object** args[] = { receiver.location(), name.location() }; 248 Object** args[] = { receiver.location(), name.location() };
248 bool has_exception; 249 bool has_exception;
249 Handle<Object> result = 250 Handle<Object> result =
250 Execution::Call(trap, handler, ARRAY_SIZE(args), args, &has_exception); 251 Execution::Call(trap, handler, ARRAY_SIZE(args), args, &has_exception);
(...skipping 1997 matching lines...) Expand 10 before | Expand all | Expand 10 after
2248 bool JSProxy::HasPropertyWithHandler(String* name_raw) { 2249 bool JSProxy::HasPropertyWithHandler(String* name_raw) {
2249 Isolate* isolate = GetIsolate(); 2250 Isolate* isolate = GetIsolate();
2250 HandleScope scope(isolate); 2251 HandleScope scope(isolate);
2251 Handle<Object> receiver(this); 2252 Handle<Object> receiver(this);
2252 Handle<Object> name(name_raw); 2253 Handle<Object> name(name_raw);
2253 Handle<Object> handler(this->handler()); 2254 Handle<Object> handler(this->handler());
2254 2255
2255 // Extract trap function. 2256 // Extract trap function.
2256 Handle<String> trap_name = isolate->factory()->LookupAsciiSymbol("has"); 2257 Handle<String> trap_name = isolate->factory()->LookupAsciiSymbol("has");
2257 Handle<Object> trap(v8::internal::GetProperty(handler, trap_name)); 2258 Handle<Object> trap(v8::internal::GetProperty(handler, trap_name));
2259 if (isolate->has_pending_exception()) return Failure::Exception();
2258 if (trap->IsUndefined()) { 2260 if (trap->IsUndefined()) {
2259 trap = isolate->derived_has_trap(); 2261 trap = isolate->derived_has_trap();
2260 } 2262 }
2261 2263
2262 // Call trap function. 2264 // Call trap function.
2263 Object** args[] = { name.location() }; 2265 Object** args[] = { name.location() };
2264 bool has_exception; 2266 bool has_exception;
2265 Handle<Object> result = 2267 Handle<Object> result =
2266 Execution::Call(trap, handler, ARRAY_SIZE(args), args, &has_exception); 2268 Execution::Call(trap, handler, ARRAY_SIZE(args), args, &has_exception);
2267 if (has_exception) return Failure::Exception(); 2269 if (has_exception) return Failure::Exception();
(...skipping 10 matching lines...) Expand all
2278 Isolate* isolate = GetIsolate(); 2280 Isolate* isolate = GetIsolate();
2279 HandleScope scope(isolate); 2281 HandleScope scope(isolate);
2280 Handle<Object> receiver(this); 2282 Handle<Object> receiver(this);
2281 Handle<Object> name(name_raw); 2283 Handle<Object> name(name_raw);
2282 Handle<Object> value(value_raw); 2284 Handle<Object> value(value_raw);
2283 Handle<Object> handler(this->handler()); 2285 Handle<Object> handler(this->handler());
2284 2286
2285 // Extract trap function. 2287 // Extract trap function.
2286 Handle<String> trap_name = isolate->factory()->LookupAsciiSymbol("set"); 2288 Handle<String> trap_name = isolate->factory()->LookupAsciiSymbol("set");
2287 Handle<Object> trap(v8::internal::GetProperty(handler, trap_name)); 2289 Handle<Object> trap(v8::internal::GetProperty(handler, trap_name));
2290 if (isolate->has_pending_exception()) return Failure::Exception();
2288 if (trap->IsUndefined()) { 2291 if (trap->IsUndefined()) {
2289 trap = isolate->derived_set_trap(); 2292 trap = isolate->derived_set_trap();
2290 } 2293 }
2291 2294
2292 // Call trap function. 2295 // Call trap function.
2293 Object** args[] = { 2296 Object** args[] = {
2294 receiver.location(), name.location(), value.location() 2297 receiver.location(), name.location(), value.location()
2295 }; 2298 };
2296 bool has_exception; 2299 bool has_exception;
2297 Execution::Call(trap, handler, ARRAY_SIZE(args), args, &has_exception); 2300 Execution::Call(trap, handler, ARRAY_SIZE(args), args, &has_exception);
2298 if (has_exception) return Failure::Exception(); 2301 if (has_exception) return Failure::Exception();
2299 2302
2300 return *value; 2303 return *value;
2301 } 2304 }
2302 2305
2303 2306
2304 MUST_USE_RESULT MaybeObject* JSProxy::DeletePropertyWithHandler( 2307 MUST_USE_RESULT MaybeObject* JSProxy::DeletePropertyWithHandler(
2305 String* name_raw, DeleteMode mode) { 2308 String* name_raw, DeleteMode mode) {
2306 Isolate* isolate = GetIsolate(); 2309 Isolate* isolate = GetIsolate();
2307 HandleScope scope(isolate); 2310 HandleScope scope(isolate);
2308 Handle<Object> receiver(this); 2311 Handle<Object> receiver(this);
2309 Handle<Object> name(name_raw); 2312 Handle<Object> name(name_raw);
2310 Handle<Object> handler(this->handler()); 2313 Handle<Object> handler(this->handler());
2311 2314
2312 // Extract trap function. 2315 // Extract trap function.
2313 Handle<String> trap_name = isolate->factory()->LookupAsciiSymbol("delete"); 2316 Handle<String> trap_name = isolate->factory()->LookupAsciiSymbol("delete");
2314 Handle<Object> trap(v8::internal::GetProperty(handler, trap_name)); 2317 Handle<Object> trap(v8::internal::GetProperty(handler, trap_name));
2318 if (isolate->has_pending_exception()) return Failure::Exception();
2315 if (trap->IsUndefined()) { 2319 if (trap->IsUndefined()) {
2316 Handle<Object> args[] = { handler, trap_name }; 2320 Handle<Object> args[] = { handler, trap_name };
2317 Handle<Object> error = isolate->factory()->NewTypeError( 2321 Handle<Object> error = isolate->factory()->NewTypeError(
2318 "handler_trap_missing", HandleVector(args, ARRAY_SIZE(args))); 2322 "handler_trap_missing", HandleVector(args, ARRAY_SIZE(args)));
2319 isolate->Throw(*error); 2323 isolate->Throw(*error);
2320 return Failure::Exception(); 2324 return Failure::Exception();
2321 } 2325 }
2322 2326
2323 // Call trap function. 2327 // Call trap function.
2324 Object** args[] = { name.location() }; 2328 Object** args[] = { name.location() };
(...skipping 21 matching lines...) Expand all
2346 Isolate* isolate = GetIsolate(); 2350 Isolate* isolate = GetIsolate();
2347 HandleScope scope(isolate); 2351 HandleScope scope(isolate);
2348 Handle<JSReceiver> receiver(receiver_raw); 2352 Handle<JSReceiver> receiver(receiver_raw);
2349 Handle<Object> name(name_raw); 2353 Handle<Object> name(name_raw);
2350 Handle<Object> handler(this->handler()); 2354 Handle<Object> handler(this->handler());
2351 2355
2352 // Extract trap function. 2356 // Extract trap function.
2353 Handle<String> trap_name = 2357 Handle<String> trap_name =
2354 isolate->factory()->LookupAsciiSymbol("getPropertyDescriptor"); 2358 isolate->factory()->LookupAsciiSymbol("getPropertyDescriptor");
2355 Handle<Object> trap(v8::internal::GetProperty(handler, trap_name)); 2359 Handle<Object> trap(v8::internal::GetProperty(handler, trap_name));
2360 if (isolate->has_pending_exception()) return NONE;
2356 if (trap->IsUndefined()) { 2361 if (trap->IsUndefined()) {
2357 Handle<Object> args[] = { handler, trap_name }; 2362 Handle<Object> args[] = { handler, trap_name };
2358 Handle<Object> error = isolate->factory()->NewTypeError( 2363 Handle<Object> error = isolate->factory()->NewTypeError(
2359 "handler_trap_missing", HandleVector(args, ARRAY_SIZE(args))); 2364 "handler_trap_missing", HandleVector(args, ARRAY_SIZE(args)));
2360 isolate->Throw(*error); 2365 isolate->Throw(*error);
2361 *has_exception = true; 2366 *has_exception = true;
2362 return NONE; 2367 return NONE;
2363 } 2368 }
2364 2369
2365 // Call trap function. 2370 // Call trap function.
(...skipping 9230 matching lines...) Expand 10 before | Expand all | Expand 10 after
11596 if (break_point_objects()->IsUndefined()) return 0; 11601 if (break_point_objects()->IsUndefined()) return 0;
11597 // Single break point. 11602 // Single break point.
11598 if (!break_point_objects()->IsFixedArray()) return 1; 11603 if (!break_point_objects()->IsFixedArray()) return 1;
11599 // Multiple break points. 11604 // Multiple break points.
11600 return FixedArray::cast(break_point_objects())->length(); 11605 return FixedArray::cast(break_point_objects())->length();
11601 } 11606 }
11602 #endif 11607 #endif
11603 11608
11604 11609
11605 } } // namespace v8::internal 11610 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/harmony/proxies.js » ('j') | test/mjsunit/harmony/proxies.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698