OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <sstream> | 5 #include <sstream> |
6 | 6 |
7 #include "src/v8.h" | 7 #include "src/v8.h" |
8 | 8 |
9 #include "src/accessors.h" | 9 #include "src/accessors.h" |
10 #include "src/allocation-site-scopes.h" | 10 #include "src/allocation-site-scopes.h" |
(...skipping 17049 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17060 if (old_type->Is(HeapType::None()) || old_type->Is(HeapType::Undefined())) { | 17060 if (old_type->Is(HeapType::None()) || old_type->Is(HeapType::Undefined())) { |
17061 return new_type; | 17061 return new_type; |
17062 } | 17062 } |
17063 | 17063 |
17064 return HeapType::Any(isolate); | 17064 return HeapType::Any(isolate); |
17065 } | 17065 } |
17066 | 17066 |
17067 | 17067 |
17068 Handle<Object> PropertyCell::SetValueInferType(Handle<PropertyCell> cell, | 17068 Handle<Object> PropertyCell::SetValueInferType(Handle<PropertyCell> cell, |
17069 Handle<Object> value) { | 17069 Handle<Object> value) { |
17070 // Heuristic: if a string is stored in a previously uninitialized | 17070 // Heuristic: if a small-ish string is stored in a previously uninitialized |
17071 // property cell, internalize it. | 17071 // property cell, internalize it. |
| 17072 const int kMaxLengthForInternalization = 200; |
17072 if ((cell->type()->Is(HeapType::None()) || | 17073 if ((cell->type()->Is(HeapType::None()) || |
17073 cell->type()->Is(HeapType::Undefined())) && | 17074 cell->type()->Is(HeapType::Undefined())) && |
17074 value->IsString()) { | 17075 value->IsString() && |
| 17076 Handle<String>::cast(value)->length() <= kMaxLengthForInternalization) { |
17075 value = cell->GetIsolate()->factory()->InternalizeString( | 17077 value = cell->GetIsolate()->factory()->InternalizeString( |
17076 Handle<String>::cast(value)); | 17078 Handle<String>::cast(value)); |
17077 } | 17079 } |
17078 cell->set_value(*value); | 17080 cell->set_value(*value); |
17079 if (!HeapType::Any()->Is(cell->type())) { | 17081 if (!HeapType::Any()->Is(cell->type())) { |
17080 Handle<HeapType> new_type = UpdatedType(cell, value); | 17082 Handle<HeapType> new_type = UpdatedType(cell, value); |
17081 cell->set_type(*new_type); | 17083 cell->set_type(*new_type); |
17082 } | 17084 } |
17083 return value; | 17085 return value; |
17084 } | 17086 } |
17085 | 17087 |
17086 | 17088 |
17087 // static | 17089 // static |
17088 void PropertyCell::AddDependentCompilationInfo(Handle<PropertyCell> cell, | 17090 void PropertyCell::AddDependentCompilationInfo(Handle<PropertyCell> cell, |
17089 CompilationInfo* info) { | 17091 CompilationInfo* info) { |
17090 Handle<DependentCode> codes = | 17092 Handle<DependentCode> codes = |
17091 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()), | 17093 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()), |
17092 DependentCode::kPropertyCellChangedGroup, | 17094 DependentCode::kPropertyCellChangedGroup, |
17093 info->object_wrapper()); | 17095 info->object_wrapper()); |
17094 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); | 17096 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); |
17095 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( | 17097 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( |
17096 cell, info->zone()); | 17098 cell, info->zone()); |
17097 } | 17099 } |
17098 | 17100 |
17099 } } // namespace v8::internal | 17101 } } // namespace v8::internal |
OLD | NEW |