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

Side by Side Diff: src/ast.cc

Issue 6606002: Merge revision 6500-6600 from bleeding_edge to the isolates branch. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
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 | Annotate | Revision Log
« no previous file with comments | « src/ast.h ('k') | src/bootstrapper.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 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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 208
209 209
210 bool IsEqualString(void* first, void* second) { 210 bool IsEqualString(void* first, void* second) {
211 ASSERT((*reinterpret_cast<String**>(first))->IsString()); 211 ASSERT((*reinterpret_cast<String**>(first))->IsString());
212 ASSERT((*reinterpret_cast<String**>(second))->IsString()); 212 ASSERT((*reinterpret_cast<String**>(second))->IsString());
213 Handle<String> h1(reinterpret_cast<String**>(first)); 213 Handle<String> h1(reinterpret_cast<String**>(first));
214 Handle<String> h2(reinterpret_cast<String**>(second)); 214 Handle<String> h2(reinterpret_cast<String**>(second));
215 return (*h1)->Equals(*h2); 215 return (*h1)->Equals(*h2);
216 } 216 }
217 217
218 bool IsEqualSmi(void* first, void* second) { 218
219 ASSERT((*reinterpret_cast<Smi**>(first))->IsSmi()); 219 bool IsEqualNumber(void* first, void* second) {
220 ASSERT((*reinterpret_cast<Smi**>(second))->IsSmi()); 220 ASSERT((*reinterpret_cast<Object**>(first))->IsNumber());
221 Handle<Smi> h1(reinterpret_cast<Smi**>(first)); 221 ASSERT((*reinterpret_cast<Object**>(second))->IsNumber());
222 Handle<Smi> h2(reinterpret_cast<Smi**>(second)); 222
223 return (*h1)->value() == (*h2)->value(); 223 Handle<Object> h1(reinterpret_cast<Object**>(first));
224 Handle<Object> h2(reinterpret_cast<Object**>(second));
225 if (h1->IsSmi()) {
226 return h2->IsSmi() && *h1 == *h2;
227 }
228 if (h2->IsSmi()) return false;
229 Handle<HeapNumber> n1 = Handle<HeapNumber>::cast(h1);
230 Handle<HeapNumber> n2 = Handle<HeapNumber>::cast(h2);
231 ASSERT(isfinite(n1->value()));
232 ASSERT(isfinite(n2->value()));
233 return n1->value() == n2->value();
224 } 234 }
225 235
236
226 void ObjectLiteral::CalculateEmitStore() { 237 void ObjectLiteral::CalculateEmitStore() {
227 HashMap properties(&IsEqualString); 238 HashMap properties(&IsEqualString);
228 HashMap elements(&IsEqualSmi); 239 HashMap elements(&IsEqualNumber);
229 for (int i = this->properties()->length() - 1; i >= 0; i--) { 240 for (int i = this->properties()->length() - 1; i >= 0; i--) {
230 ObjectLiteral::Property* property = this->properties()->at(i); 241 ObjectLiteral::Property* property = this->properties()->at(i);
231 Literal* literal = property->key(); 242 Literal* literal = property->key();
232 Handle<Object> handle = literal->handle(); 243 Handle<Object> handle = literal->handle();
233 244
234 if (handle->IsNull()) { 245 if (handle->IsNull()) {
235 continue; 246 continue;
236 } 247 }
237 248
238 uint32_t hash; 249 uint32_t hash;
239 HashMap* table; 250 HashMap* table;
240 void* key; 251 void* key;
241 uint32_t index;
242 Smi* smi_key_location;
243 if (handle->IsSymbol()) { 252 if (handle->IsSymbol()) {
244 Handle<String> name(String::cast(*handle)); 253 Handle<String> name(String::cast(*handle));
245 if (name->AsArrayIndex(&index)) { 254 if (name->AsArrayIndex(&hash)) {
246 smi_key_location = Smi::FromInt(index); 255 Handle<Object> key_handle = FACTORY->NewNumberFromUint(hash);
Vitaly Repeshko 2011/03/02 16:41:09 Given the number of FACTORY usages here it might m
247 key = &smi_key_location; 256 key = key_handle.location();
248 hash = index;
249 table = &elements; 257 table = &elements;
250 } else { 258 } else {
251 key = name.location(); 259 key = name.location();
252 hash = name->Hash(); 260 hash = name->Hash();
253 table = &properties; 261 table = &properties;
254 } 262 }
255 } else if (handle->ToArrayIndex(&index)) { 263 } else if (handle->ToArrayIndex(&hash)) {
256 key = handle.location(); 264 key = handle.location();
257 hash = index;
258 table = &elements; 265 table = &elements;
259 } else { 266 } else {
260 ASSERT(handle->IsNumber()); 267 ASSERT(handle->IsNumber());
261 double num = handle->Number(); 268 double num = handle->Number();
262 char arr[100]; 269 char arr[100];
263 Vector<char> buffer(arr, ARRAY_SIZE(arr)); 270 Vector<char> buffer(arr, ARRAY_SIZE(arr));
264 const char* str = DoubleToCString(num, buffer); 271 const char* str = DoubleToCString(num, buffer);
265 Handle<String> name = FACTORY->NewStringFromAscii(CStrVector(str)); 272 Handle<String> name = FACTORY->NewStringFromAscii(CStrVector(str));
266 key = name.location(); 273 key = name.location();
267 hash = name->Hash(); 274 hash = name->Hash();
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 ASSERT(check_type_ != RECEIVER_MAP_CHECK); 665 ASSERT(check_type_ != RECEIVER_MAP_CHECK);
659 holder_ = Handle<JSObject>( 666 holder_ = Handle<JSObject>(
660 oracle->GetPrototypeForPrimitiveCheck(check_type_)); 667 oracle->GetPrototypeForPrimitiveCheck(check_type_));
661 map = Handle<Map>(holder_->map()); 668 map = Handle<Map>(holder_->map());
662 } 669 }
663 is_monomorphic_ = ComputeTarget(map, name); 670 is_monomorphic_ = ComputeTarget(map, name);
664 } 671 }
665 } 672 }
666 673
667 674
668 void BinaryOperation::RecordTypeFeedback(TypeFeedbackOracle* oracle) {
669 TypeInfo left = oracle->BinaryType(this, TypeFeedbackOracle::LEFT);
670 TypeInfo right = oracle->BinaryType(this, TypeFeedbackOracle::RIGHT);
671 is_smi_only_ = left.IsSmi() && right.IsSmi();
672 }
673
674
675 void CompareOperation::RecordTypeFeedback(TypeFeedbackOracle* oracle) { 675 void CompareOperation::RecordTypeFeedback(TypeFeedbackOracle* oracle) {
676 TypeInfo left = oracle->CompareType(this, TypeFeedbackOracle::LEFT); 676 TypeInfo info = oracle->CompareType(this);
677 TypeInfo right = oracle->CompareType(this, TypeFeedbackOracle::RIGHT); 677 if (info.IsSmi()) {
678 if (left.IsSmi() && right.IsSmi()) {
679 compare_type_ = SMI_ONLY; 678 compare_type_ = SMI_ONLY;
680 } else if (left.IsNonPrimitive() && right.IsNonPrimitive()) { 679 } else if (info.IsNonPrimitive()) {
681 compare_type_ = OBJECT_ONLY; 680 compare_type_ = OBJECT_ONLY;
682 } else { 681 } else {
683 ASSERT(compare_type_ == NONE); 682 ASSERT(compare_type_ == NONE);
684 } 683 }
685 } 684 }
686 685
687 686
688 // ---------------------------------------------------------------------------- 687 // ----------------------------------------------------------------------------
689 // Implementation of AstVisitor 688 // Implementation of AstVisitor
690 689
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
1057 1056
1058 CaseClause::CaseClause(Expression* label, 1057 CaseClause::CaseClause(Expression* label,
1059 ZoneList<Statement*>* statements, 1058 ZoneList<Statement*>* statements,
1060 int pos) 1059 int pos)
1061 : label_(label), 1060 : label_(label),
1062 statements_(statements), 1061 statements_(statements),
1063 position_(pos), 1062 position_(pos),
1064 compare_type_(NONE) {} 1063 compare_type_(NONE) {}
1065 1064
1066 } } // namespace v8::internal 1065 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ast.h ('k') | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698