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

Side by Side Diff: src/objects.cc

Issue 6723001: Some Isolate usage cleanups in objects.{h,cc}. (Closed)
Patch Set: Created 9 years, 9 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
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 1241 matching lines...) Expand 10 before | Expand all | Expand 10 after
1252 MaybeObject* JSObject::AddFastProperty(String* name, 1252 MaybeObject* JSObject::AddFastProperty(String* name,
1253 Object* value, 1253 Object* value,
1254 PropertyAttributes attributes) { 1254 PropertyAttributes attributes) {
1255 ASSERT(!IsJSGlobalProxy()); 1255 ASSERT(!IsJSGlobalProxy());
1256 1256
1257 // Normalize the object if the name is an actual string (not the 1257 // Normalize the object if the name is an actual string (not the
1258 // hidden symbols) and is not a real identifier. 1258 // hidden symbols) and is not a real identifier.
1259 Isolate* isolate = GetHeap()->isolate(); 1259 Isolate* isolate = GetHeap()->isolate();
1260 StringInputBuffer buffer(name); 1260 StringInputBuffer buffer(name);
1261 if (!isolate->scanner_constants()->IsIdentifier(&buffer) 1261 if (!isolate->scanner_constants()->IsIdentifier(&buffer)
1262 && name != HEAP->hidden_symbol()) { 1262 && name != isolate->heap()->hidden_symbol()) {
1263 Object* obj; 1263 Object* obj;
1264 { MaybeObject* maybe_obj = 1264 { MaybeObject* maybe_obj =
1265 NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0); 1265 NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0);
1266 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 1266 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
1267 } 1267 }
1268 return AddSlowProperty(name, value, attributes); 1268 return AddSlowProperty(name, value, attributes);
1269 } 1269 }
1270 1270
1271 DescriptorArray* old_descriptors = map()->instance_descriptors(); 1271 DescriptorArray* old_descriptors = map()->instance_descriptors();
1272 // Compute the new index for new field. 1272 // Compute the new index for new field.
(...skipping 3931 matching lines...) Expand 10 before | Expand all | Expand 10 after
5204 } 5204 }
5205 } else { 5205 } else {
5206 isolate->objects_string_compare_buffer_b()->Reset(0, b); 5206 isolate->objects_string_compare_buffer_b()->Reset(0, b);
5207 return CompareStringContents(ia, 5207 return CompareStringContents(ia,
5208 isolate->objects_string_compare_buffer_b()); 5208 isolate->objects_string_compare_buffer_b());
5209 } 5209 }
5210 } 5210 }
5211 5211
5212 5212
5213 bool String::SlowEquals(String* other) { 5213 bool String::SlowEquals(String* other) {
5214 Heap* heap = GetHeap();
5215
5216 // Fast check: negative check with lengths. 5214 // Fast check: negative check with lengths.
5217 int len = length(); 5215 int len = length();
5218 if (len != other->length()) return false; 5216 if (len != other->length()) return false;
5219 if (len == 0) return true; 5217 if (len == 0) return true;
5220 5218
5221 // Fast check: if hash code is computed for both strings 5219 // Fast check: if hash code is computed for both strings
5222 // a fast negative check can be performed. 5220 // a fast negative check can be performed.
5223 if (HasHashCode() && other->HasHashCode()) { 5221 if (HasHashCode() && other->HasHashCode()) {
5224 if (Hash() != other->Hash()) return false; 5222 if (Hash() != other->Hash()) return false;
5225 } 5223 }
5226 5224
5227 // We know the strings are both non-empty. Compare the first chars 5225 // We know the strings are both non-empty. Compare the first chars
5228 // before we try to flatten the strings. 5226 // before we try to flatten the strings.
5229 if (this->Get(0) != other->Get(0)) return false; 5227 if (this->Get(0) != other->Get(0)) return false;
5230 5228
5231 String* lhs = this->TryFlattenGetString(); 5229 String* lhs = this->TryFlattenGetString();
5232 String* rhs = other->TryFlattenGetString(); 5230 String* rhs = other->TryFlattenGetString();
5233 5231
5234 if (StringShape(lhs).IsSequentialAscii() && 5232 if (StringShape(lhs).IsSequentialAscii() &&
5235 StringShape(rhs).IsSequentialAscii()) { 5233 StringShape(rhs).IsSequentialAscii()) {
5236 const char* str1 = SeqAsciiString::cast(lhs)->GetChars(); 5234 const char* str1 = SeqAsciiString::cast(lhs)->GetChars();
5237 const char* str2 = SeqAsciiString::cast(rhs)->GetChars(); 5235 const char* str2 = SeqAsciiString::cast(rhs)->GetChars();
5238 return CompareRawStringContents(Vector<const char>(str1, len), 5236 return CompareRawStringContents(Vector<const char>(str1, len),
5239 Vector<const char>(str2, len)); 5237 Vector<const char>(str2, len));
5240 } 5238 }
5241 5239
5242 Isolate* isolate = heap->isolate(); 5240 Isolate* isolate = GetIsolate();
5243 if (lhs->IsFlat()) { 5241 if (lhs->IsFlat()) {
5244 if (lhs->IsAsciiRepresentation()) { 5242 if (lhs->IsAsciiRepresentation()) {
5245 Vector<const char> vec1 = lhs->ToAsciiVector(); 5243 Vector<const char> vec1 = lhs->ToAsciiVector();
5246 if (rhs->IsFlat()) { 5244 if (rhs->IsFlat()) {
5247 if (rhs->IsAsciiRepresentation()) { 5245 if (rhs->IsAsciiRepresentation()) {
5248 Vector<const char> vec2 = rhs->ToAsciiVector(); 5246 Vector<const char> vec2 = rhs->ToAsciiVector();
5249 return CompareRawStringContents(vec1, vec2); 5247 return CompareRawStringContents(vec1, vec2);
5250 } else { 5248 } else {
5251 VectorIterator<char> buf1(vec1); 5249 VectorIterator<char> buf1(vec1);
5252 VectorIterator<uc16> ib(rhs->ToUC16Vector()); 5250 VectorIterator<uc16> ib(rhs->ToUC16Vector());
(...skipping 4909 matching lines...) Expand 10 before | Expand all | Expand 10 after
10162 if (break_point_objects()->IsUndefined()) return 0; 10160 if (break_point_objects()->IsUndefined()) return 0;
10163 // Single beak point. 10161 // Single beak point.
10164 if (!break_point_objects()->IsFixedArray()) return 1; 10162 if (!break_point_objects()->IsFixedArray()) return 1;
10165 // Multiple break points. 10163 // Multiple break points.
10166 return FixedArray::cast(break_point_objects())->length(); 10164 return FixedArray::cast(break_point_objects())->length();
10167 } 10165 }
10168 #endif 10166 #endif
10169 10167
10170 10168
10171 } } // namespace v8::internal 10169 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | src/objects-inl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698