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

Side by Side Diff: src/handles.cc

Issue 231883007: Return MaybeHandle from Invoke. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 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
« src/execution.cc ('K') | « src/handles.h ('k') | src/ic.cc » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 Handle<Object> GetScriptNameOrSourceURL(Handle<Script> script) { 399 Handle<Object> GetScriptNameOrSourceURL(Handle<Script> script) {
400 Isolate* isolate = script->GetIsolate(); 400 Isolate* isolate = script->GetIsolate();
401 Handle<String> name_or_source_url_key = 401 Handle<String> name_or_source_url_key =
402 isolate->factory()->InternalizeOneByteString( 402 isolate->factory()->InternalizeOneByteString(
403 STATIC_ASCII_VECTOR("nameOrSourceURL")); 403 STATIC_ASCII_VECTOR("nameOrSourceURL"));
404 Handle<JSValue> script_wrapper = GetScriptWrapper(script); 404 Handle<JSValue> script_wrapper = GetScriptWrapper(script);
405 Handle<Object> property = 405 Handle<Object> property =
406 Object::GetProperty(script_wrapper, name_or_source_url_key); 406 Object::GetProperty(script_wrapper, name_or_source_url_key);
407 ASSERT(property->IsJSFunction()); 407 ASSERT(property->IsJSFunction());
408 Handle<JSFunction> method = Handle<JSFunction>::cast(property); 408 Handle<JSFunction> method = Handle<JSFunction>::cast(property);
409 bool caught_exception; 409 Handle<Object> result;
410 Handle<Object> result = Execution::TryCall(method, script_wrapper, 0, 410 if (Execution::TryCall(method, script_wrapper, 0, NULL).ToHandle(&result)) {
411 NULL, &caught_exception); 411 return result;
412 if (caught_exception) {
413 result = isolate->factory()->undefined_value();
414 } 412 }
415 return result; 413 return isolate->factory()->undefined_value();
416 } 414 }
417 415
418 416
419 static bool ContainsOnlyValidKeys(Handle<FixedArray> array) { 417 static bool ContainsOnlyValidKeys(Handle<FixedArray> array) {
420 int len = array->length(); 418 int len = array->length();
421 for (int i = 0; i < len; i++) { 419 for (int i = 0; i < len; i++) {
422 Object* e = array->get(i); 420 Object* e = array->get(i);
423 if (!(e->IsString() || e->IsNumber())) return false; 421 if (!(e->IsString() || e->IsNumber())) return false;
424 } 422 }
425 return true; 423 return true;
(...skipping 12 matching lines...) Expand all
438 JSFunction::cast(arguments_boilerplate->map()->constructor()), 436 JSFunction::cast(arguments_boilerplate->map()->constructor()),
439 isolate); 437 isolate);
440 438
441 // Only collect keys if access is permitted. 439 // Only collect keys if access is permitted.
442 for (Handle<Object> p = object; 440 for (Handle<Object> p = object;
443 *p != isolate->heap()->null_value(); 441 *p != isolate->heap()->null_value();
444 p = Handle<Object>(p->GetPrototype(isolate), isolate)) { 442 p = Handle<Object>(p->GetPrototype(isolate), isolate)) {
445 if (p->IsJSProxy()) { 443 if (p->IsJSProxy()) {
446 Handle<JSProxy> proxy(JSProxy::cast(*p), isolate); 444 Handle<JSProxy> proxy(JSProxy::cast(*p), isolate);
447 Handle<Object> args[] = { proxy }; 445 Handle<Object> args[] = { proxy };
448 bool has_pending_exception; 446 Handle<Object> names;
449 Handle<Object> names = Execution::Call(isolate, 447 ASSIGN_RETURN_ON_EXCEPTION(
450 isolate->proxy_enumerate(), 448 isolate, names,
451 object, 449 Execution::Call(isolate,
452 ARRAY_SIZE(args), 450 isolate->proxy_enumerate(),
453 args, 451 object,
454 &has_pending_exception); 452 ARRAY_SIZE(args),
455 if (has_pending_exception) return MaybeHandle<FixedArray>(); 453 args),
454 FixedArray);
456 ASSIGN_RETURN_ON_EXCEPTION( 455 ASSIGN_RETURN_ON_EXCEPTION(
457 isolate, content, 456 isolate, content,
458 FixedArray::AddKeysFromJSArray(content, Handle<JSArray>::cast(names)), 457 FixedArray::AddKeysFromJSArray(
458 content, Handle<JSArray>::cast(names)),
459 FixedArray); 459 FixedArray);
460 break; 460 break;
461 } 461 }
462 462
463 Handle<JSObject> current(JSObject::cast(*p), isolate); 463 Handle<JSObject> current(JSObject::cast(*p), isolate);
464 464
465 // Check access rights if required. 465 // Check access rights if required.
466 if (current->IsAccessCheckNeeded() && 466 if (current->IsAccessCheckNeeded() &&
467 !isolate->MayNamedAccessWrapper(current, 467 !isolate->MayNamedAccessWrapper(current,
468 isolate->factory()->undefined_value(), 468 isolate->factory()->undefined_value(),
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 isolate, content, 529 isolate, content,
530 FixedArray::AddKeysFromJSArray( 530 FixedArray::AddKeysFromJSArray(
531 content, v8::Utils::OpenHandle(*result)), 531 content, v8::Utils::OpenHandle(*result)),
532 FixedArray); 532 FixedArray);
533 } 533 }
534 ASSERT(ContainsOnlyValidKeys(content)); 534 ASSERT(ContainsOnlyValidKeys(content));
535 } 535 }
536 536
537 // If we only want local properties we bail out after the first 537 // If we only want local properties we bail out after the first
538 // iteration. 538 // iteration.
539 if (type == LOCAL_ONLY) 539 if (type == LOCAL_ONLY) break;
540 break;
541 } 540 }
542 return content; 541 return content;
543 } 542 }
544 543
545 544
546 MaybeHandle<JSArray> GetKeysFor(Handle<JSReceiver> object) {
547 Isolate* isolate = object->GetIsolate();
548 isolate->counters()->for_in()->Increment();
549 Handle<FixedArray> elements;
550 ASSIGN_RETURN_ON_EXCEPTION(
551 isolate, elements,
552 GetKeysInFixedArrayFor(object, INCLUDE_PROTOS),
553 JSArray);
554 return isolate->factory()->NewJSArrayWithElements(elements);
555 }
556
557
558 Handle<FixedArray> ReduceFixedArrayTo(Handle<FixedArray> array, int length) { 545 Handle<FixedArray> ReduceFixedArrayTo(Handle<FixedArray> array, int length) {
559 ASSERT(array->length() >= length); 546 ASSERT(array->length() >= length);
560 if (array->length() == length) return array; 547 if (array->length() == length) return array;
561 548
562 Handle<FixedArray> new_array = 549 Handle<FixedArray> new_array =
563 array->GetIsolate()->factory()->NewFixedArray(length); 550 array->GetIsolate()->factory()->NewFixedArray(length);
564 for (int i = 0; i < length; ++i) new_array->set(i, array->get(i)); 551 for (int i = 0; i < length; ++i) new_array->set(i, array->get(i));
565 return new_array; 552 return new_array;
566 } 553 }
567 554
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 Handle<Code> code) { 701 Handle<Code> code) {
715 heap->EnsureWeakObjectToCodeTable(); 702 heap->EnsureWeakObjectToCodeTable();
716 Handle<DependentCode> dep(heap->LookupWeakObjectToCodeDependency(*object)); 703 Handle<DependentCode> dep(heap->LookupWeakObjectToCodeDependency(*object));
717 dep = DependentCode::Insert(dep, DependentCode::kWeaklyEmbeddedGroup, code); 704 dep = DependentCode::Insert(dep, DependentCode::kWeaklyEmbeddedGroup, code);
718 CALL_HEAP_FUNCTION_VOID(heap->isolate(), 705 CALL_HEAP_FUNCTION_VOID(heap->isolate(),
719 heap->AddWeakObjectToCodeDependency(*object, *dep)); 706 heap->AddWeakObjectToCodeDependency(*object, *dep));
720 } 707 }
721 708
722 709
723 } } // namespace v8::internal 710 } } // namespace v8::internal
OLDNEW
« src/execution.cc ('K') | « src/handles.h ('k') | src/ic.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698