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

Side by Side Diff: src/builtins.cc

Issue 231103002: Object::GetElements() and friends maybehandlification. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: FixedArray::UnionOfKeys() maybehandlified 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
« no previous file with comments | « src/bootstrapper.cc ('k') | src/debug.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 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 362
363 363
364 MUST_USE_RESULT static MaybeObject* CallJsBuiltin( 364 MUST_USE_RESULT static MaybeObject* CallJsBuiltin(
365 Isolate* isolate, 365 Isolate* isolate,
366 const char* name, 366 const char* name,
367 BuiltinArguments<NO_EXTRA_ARGUMENTS> args) { 367 BuiltinArguments<NO_EXTRA_ARGUMENTS> args) {
368 HandleScope handleScope(isolate); 368 HandleScope handleScope(isolate);
369 369
370 Handle<Object> js_builtin = 370 Handle<Object> js_builtin =
371 GetProperty(Handle<JSObject>(isolate->native_context()->builtins()), 371 GetProperty(Handle<JSObject>(isolate->native_context()->builtins()),
372 name); 372 name).ToHandleChecked();
373 Handle<JSFunction> function = Handle<JSFunction>::cast(js_builtin); 373 Handle<JSFunction> function = Handle<JSFunction>::cast(js_builtin);
374 int argc = args.length() - 1; 374 int argc = args.length() - 1;
375 ScopedVector<Handle<Object> > argv(argc); 375 ScopedVector<Handle<Object> > argv(argc);
376 for (int i = 0; i < argc; ++i) { 376 for (int i = 0; i < argc; ++i) {
377 argv[i] = args.at<Object>(i + 1); 377 argv[i] = args.at<Object>(i + 1);
378 } 378 }
379 bool pending_exception; 379 bool pending_exception;
380 Handle<Object> result = Execution::Call(isolate, 380 Handle<Object> result = Execution::Call(isolate,
381 function, 381 function,
382 args.receiver(), 382 args.receiver(),
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 } 507 }
508 508
509 Handle<JSArray> array = Handle<JSArray>::cast(receiver); 509 Handle<JSArray> array = Handle<JSArray>::cast(receiver);
510 ASSERT(!array->map()->is_observed()); 510 ASSERT(!array->map()->is_observed());
511 511
512 int len = Smi::cast(array->length())->value(); 512 int len = Smi::cast(array->length())->value();
513 if (len == 0) return isolate->heap()->undefined_value(); 513 if (len == 0) return isolate->heap()->undefined_value();
514 514
515 ElementsAccessor* accessor = array->GetElementsAccessor(); 515 ElementsAccessor* accessor = array->GetElementsAccessor();
516 int new_length = len - 1; 516 int new_length = len - 1;
517 Handle<Object> element; 517 MaybeHandle<Object> maybe_element;
518 if (accessor->HasElement(array, array, new_length, elms_obj)) { 518 if (accessor->HasElement(array, array, new_length, elms_obj)) {
519 element = accessor->Get( 519 maybe_element = accessor->Get(array, array, new_length, elms_obj);
520 array, array, new_length, elms_obj);
521 } else { 520 } else {
522 Handle<Object> proto(array->GetPrototype(), isolate); 521 Handle<Object> proto(array->GetPrototype(), isolate);
523 element = Object::GetElement(isolate, proto, len - 1); 522 maybe_element = Object::GetElement(isolate, proto, len - 1);
524 } 523 }
525 RETURN_IF_EMPTY_HANDLE(isolate, element); 524 Handle<Object> element;
526 RETURN_IF_EMPTY_HANDLE(isolate, 525 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, element, maybe_element);
527 accessor->SetLength( 526 RETURN_IF_EMPTY_HANDLE(
528 array, handle(Smi::FromInt(new_length), isolate))); 527 isolate,
528 accessor->SetLength(array, handle(Smi::FromInt(new_length), isolate)));
529 return *element; 529 return *element;
530 } 530 }
531 531
532 532
533 BUILTIN(ArrayShift) { 533 BUILTIN(ArrayShift) {
534 HandleScope scope(isolate); 534 HandleScope scope(isolate);
535 Heap* heap = isolate->heap(); 535 Heap* heap = isolate->heap();
536 Handle<Object> receiver = args.receiver(); 536 Handle<Object> receiver = args.receiver();
537 MaybeHandle<FixedArrayBase> maybe_elms_obj = 537 MaybeHandle<FixedArrayBase> maybe_elms_obj =
538 EnsureJSArrayWithWritableFastElements(isolate, receiver, NULL, 0); 538 EnsureJSArrayWithWritableFastElements(isolate, receiver, NULL, 0);
539 Handle<FixedArrayBase> elms_obj; 539 Handle<FixedArrayBase> elms_obj;
540 if (!maybe_elms_obj.ToHandle(&elms_obj) || 540 if (!maybe_elms_obj.ToHandle(&elms_obj) ||
541 !IsJSArrayFastElementMovingAllowed(heap, 541 !IsJSArrayFastElementMovingAllowed(heap,
542 *Handle<JSArray>::cast(receiver))) { 542 *Handle<JSArray>::cast(receiver))) {
543 return CallJsBuiltin(isolate, "ArrayShift", args); 543 return CallJsBuiltin(isolate, "ArrayShift", args);
544 } 544 }
545 Handle<JSArray> array = Handle<JSArray>::cast(receiver); 545 Handle<JSArray> array = Handle<JSArray>::cast(receiver);
546 ASSERT(!array->map()->is_observed()); 546 ASSERT(!array->map()->is_observed());
547 547
548 int len = Smi::cast(array->length())->value(); 548 int len = Smi::cast(array->length())->value();
549 if (len == 0) return heap->undefined_value(); 549 if (len == 0) return heap->undefined_value();
550 550
551 // Get first element 551 // Get first element
552 ElementsAccessor* accessor = array->GetElementsAccessor(); 552 ElementsAccessor* accessor = array->GetElementsAccessor();
553 Handle<Object> first = accessor->Get(receiver, array, 0, elms_obj); 553 Handle<Object> first;
554 RETURN_IF_EMPTY_HANDLE(isolate, first); 554 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
555 isolate, first, accessor->Get(receiver, array, 0, elms_obj));
555 if (first->IsTheHole()) { 556 if (first->IsTheHole()) {
556 first = isolate->factory()->undefined_value(); 557 first = isolate->factory()->undefined_value();
557 } 558 }
558 559
559 if (heap->CanMoveObjectStart(*elms_obj)) { 560 if (heap->CanMoveObjectStart(*elms_obj)) {
560 array->set_elements(LeftTrimFixedArray(heap, *elms_obj, 1)); 561 array->set_elements(LeftTrimFixedArray(heap, *elms_obj, 1));
561 } else { 562 } else {
562 // Shift the elements. 563 // Shift the elements.
563 if (elms_obj->IsFixedArray()) { 564 if (elms_obj->IsFixedArray()) {
564 Handle<FixedArray> elms = Handle<FixedArray>::cast(elms_obj); 565 Handle<FixedArray> elms = Handle<FixedArray>::cast(elms_obj);
(...skipping 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after
1744 } 1745 }
1745 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) 1746 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C)
1746 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) 1747 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A)
1747 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) 1748 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H)
1748 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) 1749 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A)
1749 #undef DEFINE_BUILTIN_ACCESSOR_C 1750 #undef DEFINE_BUILTIN_ACCESSOR_C
1750 #undef DEFINE_BUILTIN_ACCESSOR_A 1751 #undef DEFINE_BUILTIN_ACCESSOR_A
1751 1752
1752 1753
1753 } } // namespace v8::internal 1754 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/bootstrapper.cc ('k') | src/debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698