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

Side by Side Diff: src/ast.cc

Issue 6606006: [Isolates] Merge 6500:6700 from bleeding_edge to isolates. (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; 252 Factory* factory = Isolate::Current()->factory();
242 Smi* smi_key_location;
243 if (handle->IsSymbol()) { 253 if (handle->IsSymbol()) {
244 Handle<String> name(String::cast(*handle)); 254 Handle<String> name(String::cast(*handle));
245 if (name->AsArrayIndex(&index)) { 255 if (name->AsArrayIndex(&hash)) {
246 smi_key_location = Smi::FromInt(index); 256 Handle<Object> key_handle = factory->NewNumberFromUint(hash);
247 key = &smi_key_location; 257 key = key_handle.location();
248 hash = index;
249 table = &elements; 258 table = &elements;
250 } else { 259 } else {
251 key = name.location(); 260 key = name.location();
252 hash = name->Hash(); 261 hash = name->Hash();
253 table = &properties; 262 table = &properties;
254 } 263 }
255 } else if (handle->ToArrayIndex(&index)) { 264 } else if (handle->ToArrayIndex(&hash)) {
256 key = handle.location(); 265 key = handle.location();
257 hash = index;
258 table = &elements; 266 table = &elements;
259 } else { 267 } else {
260 ASSERT(handle->IsNumber()); 268 ASSERT(handle->IsNumber());
261 double num = handle->Number(); 269 double num = handle->Number();
262 char arr[100]; 270 char arr[100];
263 Vector<char> buffer(arr, ARRAY_SIZE(arr)); 271 Vector<char> buffer(arr, ARRAY_SIZE(arr));
264 const char* str = DoubleToCString(num, buffer); 272 const char* str = DoubleToCString(num, buffer);
265 Handle<String> name = FACTORY->NewStringFromAscii(CStrVector(str)); 273 Handle<String> name = factory->NewStringFromAscii(CStrVector(str));
266 key = name.location(); 274 key = name.location();
267 hash = name->Hash(); 275 hash = name->Hash();
268 table = &properties; 276 table = &properties;
269 } 277 }
270 // If the key of a computed property is in the table, do not emit 278 // If the key of a computed property is in the table, do not emit
271 // a store for the property later. 279 // a store for the property later.
272 if (property->kind() == ObjectLiteral::Property::COMPUTED) { 280 if (property->kind() == ObjectLiteral::Property::COMPUTED) {
273 if (table->Lookup(key, hash, false) != NULL) { 281 if (table->Lookup(key, hash, false) != NULL) {
274 property->set_emit_store(false); 282 property->set_emit_store(false);
275 } 283 }
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 ASSERT(check_type_ != RECEIVER_MAP_CHECK); 666 ASSERT(check_type_ != RECEIVER_MAP_CHECK);
659 holder_ = Handle<JSObject>( 667 holder_ = Handle<JSObject>(
660 oracle->GetPrototypeForPrimitiveCheck(check_type_)); 668 oracle->GetPrototypeForPrimitiveCheck(check_type_));
661 map = Handle<Map>(holder_->map()); 669 map = Handle<Map>(holder_->map());
662 } 670 }
663 is_monomorphic_ = ComputeTarget(map, name); 671 is_monomorphic_ = ComputeTarget(map, name);
664 } 672 }
665 } 673 }
666 674
667 675
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) { 676 void CompareOperation::RecordTypeFeedback(TypeFeedbackOracle* oracle) {
676 TypeInfo left = oracle->CompareType(this, TypeFeedbackOracle::LEFT); 677 TypeInfo info = oracle->CompareType(this);
677 TypeInfo right = oracle->CompareType(this, TypeFeedbackOracle::RIGHT); 678 if (info.IsSmi()) {
678 if (left.IsSmi() && right.IsSmi()) {
679 compare_type_ = SMI_ONLY; 679 compare_type_ = SMI_ONLY;
680 } else if (left.IsNonPrimitive() && right.IsNonPrimitive()) { 680 } else if (info.IsNonPrimitive()) {
681 compare_type_ = OBJECT_ONLY; 681 compare_type_ = OBJECT_ONLY;
682 } else { 682 } else {
683 ASSERT(compare_type_ == NONE); 683 ASSERT(compare_type_ == NONE);
684 } 684 }
685 } 685 }
686 686
687 687
688 // ---------------------------------------------------------------------------- 688 // ----------------------------------------------------------------------------
689 // Implementation of AstVisitor 689 // Implementation of AstVisitor
690 690
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
1057 1057
1058 CaseClause::CaseClause(Expression* label, 1058 CaseClause::CaseClause(Expression* label,
1059 ZoneList<Statement*>* statements, 1059 ZoneList<Statement*>* statements,
1060 int pos) 1060 int pos)
1061 : label_(label), 1061 : label_(label),
1062 statements_(statements), 1062 statements_(statements),
1063 position_(pos), 1063 position_(pos),
1064 compare_type_(NONE) {} 1064 compare_type_(NONE) {}
1065 1065
1066 } } // namespace v8::internal 1066 } } // 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