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

Side by Side Diff: src/objects.cc

Issue 11801036: Test fix: missing check for JSArray. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Updated Created 7 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 | no next file » | 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 9843 matching lines...) Expand 10 before | Expand all | Expand 10 after
9854 } 9854 }
9855 } 9855 }
9856 // Convert to fast double elements if appropriate. 9856 // Convert to fast double elements if appropriate.
9857 if (HasFastSmiElements() && !value->IsSmi() && value->IsNumber()) { 9857 if (HasFastSmiElements() && !value->IsSmi() && value->IsNumber()) {
9858 // Consider fixing the boilerplate as well if we have one. 9858 // Consider fixing the boilerplate as well if we have one.
9859 ElementsKind to_kind = IsHoleyElementsKind(elements_kind) 9859 ElementsKind to_kind = IsHoleyElementsKind(elements_kind)
9860 ? FAST_HOLEY_DOUBLE_ELEMENTS 9860 ? FAST_HOLEY_DOUBLE_ELEMENTS
9861 : FAST_DOUBLE_ELEMENTS; 9861 : FAST_DOUBLE_ELEMENTS;
9862 9862
9863 MaybeObject* trans = PossiblyTransitionArrayBoilerplate(to_kind); 9863 MaybeObject* trans = PossiblyTransitionArrayBoilerplate(to_kind);
9864 if (trans != NULL && trans->IsFailure()) return trans; 9864 if (trans->IsFailure()) return trans;
9865 9865
9866 MaybeObject* maybe = 9866 MaybeObject* maybe =
9867 SetFastDoubleElementsCapacityAndLength(new_capacity, array_length); 9867 SetFastDoubleElementsCapacityAndLength(new_capacity, array_length);
9868 if (maybe->IsFailure()) return maybe; 9868 if (maybe->IsFailure()) return maybe;
9869 FixedDoubleArray::cast(elements())->set(index, value->Number()); 9869 FixedDoubleArray::cast(elements())->set(index, value->Number());
9870 ValidateElements(); 9870 ValidateElements();
9871 return value; 9871 return value;
9872 } 9872 }
9873 // Change elements kind from Smi-only to generic FAST if necessary. 9873 // Change elements kind from Smi-only to generic FAST if necessary.
9874 if (HasFastSmiElements() && !value->IsSmi()) { 9874 if (HasFastSmiElements() && !value->IsSmi()) {
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
10399 Handle<Object> JSObject::TransitionElementsKind(Handle<JSObject> object, 10399 Handle<Object> JSObject::TransitionElementsKind(Handle<JSObject> object,
10400 ElementsKind to_kind) { 10400 ElementsKind to_kind) {
10401 CALL_HEAP_FUNCTION(object->GetIsolate(), 10401 CALL_HEAP_FUNCTION(object->GetIsolate(),
10402 object->TransitionElementsKind(to_kind), 10402 object->TransitionElementsKind(to_kind),
10403 Object); 10403 Object);
10404 } 10404 }
10405 10405
10406 10406
10407 MaybeObject* JSObject::PossiblyTransitionArrayBoilerplate( 10407 MaybeObject* JSObject::PossiblyTransitionArrayBoilerplate(
10408 ElementsKind to_kind) { 10408 ElementsKind to_kind) {
10409 ASSERT(IsJSArray());
10410 MaybeObject* ret = NULL; 10409 MaybeObject* ret = NULL;
10411 AllocationSiteInfo* info = AllocationSiteInfo::FindForJSObject(this); 10410 if (IsJSArray()) {
10412 if (info != NULL) { 10411 AllocationSiteInfo* info = AllocationSiteInfo::FindForJSObject(this);
10413 JSObject* payload = JSObject::cast(info->payload()); 10412 if (info != NULL) {
10414 if (payload->GetElementsKind() != to_kind) { 10413 JSObject* payload = JSObject::cast(info->payload());
10415 if (IsMoreGeneralElementsKindTransition(payload->GetElementsKind(), 10414 if (payload->GetElementsKind() != to_kind) {
10416 to_kind)) { 10415 if (IsMoreGeneralElementsKindTransition(payload->GetElementsKind(),
10417 ret = payload->TransitionElementsKind(to_kind); 10416 to_kind)) {
10417 ret = payload->TransitionElementsKind(to_kind);
10418 }
10418 } 10419 }
10419 } 10420 }
10420 } 10421 }
10421 return ret; 10422 return ret;
10422 } 10423 }
10423 10424
10424 10425
10425 MaybeObject* JSObject::TransitionElementsKind(ElementsKind to_kind) { 10426 MaybeObject* JSObject::TransitionElementsKind(ElementsKind to_kind) {
10426 ASSERT(!map()->is_observed()); 10427 ASSERT(!map()->is_observed());
10427 ElementsKind from_kind = map()->elements_kind(); 10428 ElementsKind from_kind = map()->elements_kind();
10428 10429
10429 if (IsFastHoleyElementsKind(from_kind)) { 10430 if (IsFastHoleyElementsKind(from_kind)) {
10430 to_kind = GetHoleyElementsKind(to_kind); 10431 to_kind = GetHoleyElementsKind(to_kind);
10431 } 10432 }
10432 10433
10433 if (from_kind == to_kind) return this; 10434 if (from_kind == to_kind) return this;
10434 10435
10435 MaybeObject* trans = PossiblyTransitionArrayBoilerplate(to_kind); 10436 MaybeObject* trans = PossiblyTransitionArrayBoilerplate(to_kind);
10436 if (trans != NULL && trans->IsFailure()) return trans; 10437 if (trans->IsFailure()) return trans;
10437 10438
10438 Isolate* isolate = GetIsolate(); 10439 Isolate* isolate = GetIsolate();
10439 if (elements() == isolate->heap()->empty_fixed_array() || 10440 if (elements() == isolate->heap()->empty_fixed_array() ||
10440 (IsFastSmiOrObjectElementsKind(from_kind) && 10441 (IsFastSmiOrObjectElementsKind(from_kind) &&
10441 IsFastSmiOrObjectElementsKind(to_kind)) || 10442 IsFastSmiOrObjectElementsKind(to_kind)) ||
10442 (from_kind == FAST_DOUBLE_ELEMENTS && 10443 (from_kind == FAST_DOUBLE_ELEMENTS &&
10443 to_kind == FAST_HOLEY_DOUBLE_ELEMENTS)) { 10444 to_kind == FAST_HOLEY_DOUBLE_ELEMENTS)) {
10444 ASSERT(from_kind != TERMINAL_FAST_ELEMENTS_KIND); 10445 ASSERT(from_kind != TERMINAL_FAST_ELEMENTS_KIND);
10445 // No change is needed to the elements() buffer, the transition 10446 // No change is needed to the elements() buffer, the transition
10446 // only requires a map change. 10447 // only requires a map change.
(...skipping 3332 matching lines...) Expand 10 before | Expand all | Expand 10 after
13779 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); 13780 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER);
13780 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); 13781 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER);
13781 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); 13782 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER);
13782 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); 13783 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER);
13783 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); 13784 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER);
13784 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); 13785 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER);
13785 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); 13786 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER);
13786 } 13787 }
13787 13788
13788 } } // namespace v8::internal 13789 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698