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

Side by Side Diff: src/ast.cc

Issue 10534006: Remove TLS access for current Zone. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review. Created 8 years, 6 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/compiler.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 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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 } 235 }
236 if (h2->IsSmi()) return false; 236 if (h2->IsSmi()) return false;
237 Handle<HeapNumber> n1 = Handle<HeapNumber>::cast(h1); 237 Handle<HeapNumber> n1 = Handle<HeapNumber>::cast(h1);
238 Handle<HeapNumber> n2 = Handle<HeapNumber>::cast(h2); 238 Handle<HeapNumber> n2 = Handle<HeapNumber>::cast(h2);
239 ASSERT(isfinite(n1->value())); 239 ASSERT(isfinite(n1->value()));
240 ASSERT(isfinite(n2->value())); 240 ASSERT(isfinite(n2->value()));
241 return n1->value() == n2->value(); 241 return n1->value() == n2->value();
242 } 242 }
243 243
244 244
245 void ObjectLiteral::CalculateEmitStore() { 245 void ObjectLiteral::CalculateEmitStore(Zone* zone) {
246 ZoneHashMap table(Literal::Match); 246 ZoneAllocationPolicy allocator(zone);
247
248 ZoneHashMap table(Literal::Match, ZoneHashMap::kDefaultHashMapCapacity,
249 allocator);
247 for (int i = properties()->length() - 1; i >= 0; i--) { 250 for (int i = properties()->length() - 1; i >= 0; i--) {
248 ObjectLiteral::Property* property = properties()->at(i); 251 ObjectLiteral::Property* property = properties()->at(i);
249 Literal* literal = property->key(); 252 Literal* literal = property->key();
250 if (literal->handle()->IsNull()) continue; 253 if (literal->handle()->IsNull()) continue;
251 uint32_t hash = literal->Hash(); 254 uint32_t hash = literal->Hash();
252 // If the key of a computed property is in the table, do not emit 255 // If the key of a computed property is in the table, do not emit
253 // a store for the property later. 256 // a store for the property later.
254 if (property->kind() == ObjectLiteral::Property::COMPUTED && 257 if (property->kind() == ObjectLiteral::Property::COMPUTED &&
255 table.Lookup(literal, hash, false) != NULL) { 258 table.Lookup(literal, hash, false, allocator) != NULL) {
256 property->set_emit_store(false); 259 property->set_emit_store(false);
257 } else { 260 } else {
258 // Add key to the table. 261 // Add key to the table.
259 table.Lookup(literal, hash, true); 262 table.Lookup(literal, hash, true, allocator);
260 } 263 }
261 } 264 }
262 } 265 }
263 266
264 267
265 void TargetCollector::AddTarget(Label* target) { 268 void TargetCollector::AddTarget(Label* target, Zone* zone) {
266 // Add the label to the collector, but discard duplicates. 269 // Add the label to the collector, but discard duplicates.
267 int length = targets_.length(); 270 int length = targets_.length();
268 for (int i = 0; i < length; i++) { 271 for (int i = 0; i < length; i++) {
269 if (targets_[i] == target) return; 272 if (targets_[i] == target) return;
270 } 273 }
271 targets_.Add(target); 274 targets_.Add(target, zone);
272 } 275 }
273 276
274 277
275 bool UnaryOperation::ResultOverwriteAllowed() { 278 bool UnaryOperation::ResultOverwriteAllowed() {
276 switch (op_) { 279 switch (op_) {
277 case Token::BIT_NOT: 280 case Token::BIT_NOT:
278 case Token::SUB: 281 case Token::SUB:
279 return true; 282 return true;
280 default: 283 default:
281 return false; 284 return false;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 } 393 }
391 394
392 bool FunctionDeclaration::IsInlineable() const { 395 bool FunctionDeclaration::IsInlineable() const {
393 return false; 396 return false;
394 } 397 }
395 398
396 399
397 // ---------------------------------------------------------------------------- 400 // ----------------------------------------------------------------------------
398 // Recording of type feedback 401 // Recording of type feedback
399 402
400 void Property::RecordTypeFeedback(TypeFeedbackOracle* oracle) { 403 void Property::RecordTypeFeedback(TypeFeedbackOracle* oracle,
404 Zone* zone) {
401 // Record type feedback from the oracle in the AST. 405 // Record type feedback from the oracle in the AST.
402 is_uninitialized_ = oracle->LoadIsUninitialized(this); 406 is_uninitialized_ = oracle->LoadIsUninitialized(this);
403 if (is_uninitialized_) return; 407 if (is_uninitialized_) return;
404 408
405 is_monomorphic_ = oracle->LoadIsMonomorphicNormal(this); 409 is_monomorphic_ = oracle->LoadIsMonomorphicNormal(this);
406 receiver_types_.Clear(); 410 receiver_types_.Clear();
407 if (key()->IsPropertyName()) { 411 if (key()->IsPropertyName()) {
408 if (oracle->LoadIsBuiltin(this, Builtins::kLoadIC_ArrayLength)) { 412 if (oracle->LoadIsBuiltin(this, Builtins::kLoadIC_ArrayLength)) {
409 is_array_length_ = true; 413 is_array_length_ = true;
410 } else if (oracle->LoadIsBuiltin(this, Builtins::kLoadIC_StringLength)) { 414 } else if (oracle->LoadIsBuiltin(this, Builtins::kLoadIC_StringLength)) {
411 is_string_length_ = true; 415 is_string_length_ = true;
412 } else if (oracle->LoadIsBuiltin(this, 416 } else if (oracle->LoadIsBuiltin(this,
413 Builtins::kLoadIC_FunctionPrototype)) { 417 Builtins::kLoadIC_FunctionPrototype)) {
414 is_function_prototype_ = true; 418 is_function_prototype_ = true;
415 } else { 419 } else {
416 Literal* lit_key = key()->AsLiteral(); 420 Literal* lit_key = key()->AsLiteral();
417 ASSERT(lit_key != NULL && lit_key->handle()->IsString()); 421 ASSERT(lit_key != NULL && lit_key->handle()->IsString());
418 Handle<String> name = Handle<String>::cast(lit_key->handle()); 422 Handle<String> name = Handle<String>::cast(lit_key->handle());
419 oracle->LoadReceiverTypes(this, name, &receiver_types_); 423 oracle->LoadReceiverTypes(this, name, &receiver_types_);
420 } 424 }
421 } else if (oracle->LoadIsBuiltin(this, Builtins::kKeyedLoadIC_String)) { 425 } else if (oracle->LoadIsBuiltin(this, Builtins::kKeyedLoadIC_String)) {
422 is_string_access_ = true; 426 is_string_access_ = true;
423 } else if (is_monomorphic_) { 427 } else if (is_monomorphic_) {
424 receiver_types_.Add(oracle->LoadMonomorphicReceiverType(this)); 428 receiver_types_.Add(oracle->LoadMonomorphicReceiverType(this),
429 zone);
425 } else if (oracle->LoadIsMegamorphicWithTypeInfo(this)) { 430 } else if (oracle->LoadIsMegamorphicWithTypeInfo(this)) {
426 receiver_types_.Reserve(kMaxKeyedPolymorphism); 431 receiver_types_.Reserve(kMaxKeyedPolymorphism, zone);
427 oracle->CollectKeyedReceiverTypes(this->id(), &receiver_types_); 432 oracle->CollectKeyedReceiverTypes(this->id(), &receiver_types_);
428 } 433 }
429 } 434 }
430 435
431 436
432 void Assignment::RecordTypeFeedback(TypeFeedbackOracle* oracle) { 437 void Assignment::RecordTypeFeedback(TypeFeedbackOracle* oracle,
438 Zone* zone) {
433 Property* prop = target()->AsProperty(); 439 Property* prop = target()->AsProperty();
434 ASSERT(prop != NULL); 440 ASSERT(prop != NULL);
435 is_monomorphic_ = oracle->StoreIsMonomorphicNormal(this); 441 is_monomorphic_ = oracle->StoreIsMonomorphicNormal(this);
436 receiver_types_.Clear(); 442 receiver_types_.Clear();
437 if (prop->key()->IsPropertyName()) { 443 if (prop->key()->IsPropertyName()) {
438 Literal* lit_key = prop->key()->AsLiteral(); 444 Literal* lit_key = prop->key()->AsLiteral();
439 ASSERT(lit_key != NULL && lit_key->handle()->IsString()); 445 ASSERT(lit_key != NULL && lit_key->handle()->IsString());
440 Handle<String> name = Handle<String>::cast(lit_key->handle()); 446 Handle<String> name = Handle<String>::cast(lit_key->handle());
441 oracle->StoreReceiverTypes(this, name, &receiver_types_); 447 oracle->StoreReceiverTypes(this, name, &receiver_types_);
442 } else if (is_monomorphic_) { 448 } else if (is_monomorphic_) {
443 // Record receiver type for monomorphic keyed stores. 449 // Record receiver type for monomorphic keyed stores.
444 receiver_types_.Add(oracle->StoreMonomorphicReceiverType(this)); 450 receiver_types_.Add(oracle->StoreMonomorphicReceiverType(this), zone);
445 } else if (oracle->StoreIsMegamorphicWithTypeInfo(this)) { 451 } else if (oracle->StoreIsMegamorphicWithTypeInfo(this)) {
446 receiver_types_.Reserve(kMaxKeyedPolymorphism); 452 receiver_types_.Reserve(kMaxKeyedPolymorphism, zone);
447 oracle->CollectKeyedReceiverTypes(this->id(), &receiver_types_); 453 oracle->CollectKeyedReceiverTypes(this->id(), &receiver_types_);
448 } 454 }
449 } 455 }
450 456
451 457
452 void CountOperation::RecordTypeFeedback(TypeFeedbackOracle* oracle) { 458 void CountOperation::RecordTypeFeedback(TypeFeedbackOracle* oracle,
459 Zone* zone) {
453 is_monomorphic_ = oracle->StoreIsMonomorphicNormal(this); 460 is_monomorphic_ = oracle->StoreIsMonomorphicNormal(this);
454 receiver_types_.Clear(); 461 receiver_types_.Clear();
455 if (is_monomorphic_) { 462 if (is_monomorphic_) {
456 // Record receiver type for monomorphic keyed stores. 463 // Record receiver type for monomorphic keyed stores.
457 receiver_types_.Add(oracle->StoreMonomorphicReceiverType(this)); 464 receiver_types_.Add(oracle->StoreMonomorphicReceiverType(this), zone);
458 } else if (oracle->StoreIsMegamorphicWithTypeInfo(this)) { 465 } else if (oracle->StoreIsMegamorphicWithTypeInfo(this)) {
459 receiver_types_.Reserve(kMaxKeyedPolymorphism); 466 receiver_types_.Reserve(kMaxKeyedPolymorphism, zone);
460 oracle->CollectKeyedReceiverTypes(this->id(), &receiver_types_); 467 oracle->CollectKeyedReceiverTypes(this->id(), &receiver_types_);
461 } 468 }
462 } 469 }
463 470
464 471
465 void CaseClause::RecordTypeFeedback(TypeFeedbackOracle* oracle) { 472 void CaseClause::RecordTypeFeedback(TypeFeedbackOracle* oracle) {
466 TypeInfo info = oracle->SwitchType(this); 473 TypeInfo info = oracle->SwitchType(this);
467 if (info.IsSmi()) { 474 if (info.IsSmi()) {
468 compare_type_ = SMI_ONLY; 475 compare_type_ = SMI_ONLY;
469 } else if (info.IsSymbol()) { 476 } else if (info.IsSymbol()) {
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 } 784 }
778 785
779 786
780 // Convert regular expression trees to a simple sexp representation. 787 // Convert regular expression trees to a simple sexp representation.
781 // This representation should be different from the input grammar 788 // This representation should be different from the input grammar
782 // in as many cases as possible, to make it more difficult for incorrect 789 // in as many cases as possible, to make it more difficult for incorrect
783 // parses to look as correct ones which is likely if the input and 790 // parses to look as correct ones which is likely if the input and
784 // output formats are alike. 791 // output formats are alike.
785 class RegExpUnparser: public RegExpVisitor { 792 class RegExpUnparser: public RegExpVisitor {
786 public: 793 public:
787 RegExpUnparser(); 794 explicit RegExpUnparser(Zone* zone);
788 void VisitCharacterRange(CharacterRange that); 795 void VisitCharacterRange(CharacterRange that);
789 SmartArrayPointer<const char> ToString() { return stream_.ToCString(); } 796 SmartArrayPointer<const char> ToString() { return stream_.ToCString(); }
790 #define MAKE_CASE(Name) virtual void* Visit##Name(RegExp##Name*, void* data); 797 #define MAKE_CASE(Name) virtual void* Visit##Name(RegExp##Name*, void* data);
791 FOR_EACH_REG_EXP_TREE_TYPE(MAKE_CASE) 798 FOR_EACH_REG_EXP_TREE_TYPE(MAKE_CASE)
792 #undef MAKE_CASE 799 #undef MAKE_CASE
793 private: 800 private:
794 StringStream* stream() { return &stream_; } 801 StringStream* stream() { return &stream_; }
795 HeapStringAllocator alloc_; 802 HeapStringAllocator alloc_;
796 StringStream stream_; 803 StringStream stream_;
804 Zone* zone_;
797 }; 805 };
798 806
799 807
800 RegExpUnparser::RegExpUnparser() : stream_(&alloc_) { 808 RegExpUnparser::RegExpUnparser(Zone* zone) : stream_(&alloc_), zone_(zone) {
801 } 809 }
802 810
803 811
804 void* RegExpUnparser::VisitDisjunction(RegExpDisjunction* that, void* data) { 812 void* RegExpUnparser::VisitDisjunction(RegExpDisjunction* that, void* data) {
805 stream()->Add("(|"); 813 stream()->Add("(|");
806 for (int i = 0; i < that->alternatives()->length(); i++) { 814 for (int i = 0; i < that->alternatives()->length(); i++) {
807 stream()->Add(" "); 815 stream()->Add(" ");
808 that->alternatives()->at(i)->Accept(this, data); 816 that->alternatives()->at(i)->Accept(this, data);
809 } 817 }
810 stream()->Add(")"); 818 stream()->Add(")");
(...skipping 19 matching lines...) Expand all
830 } 838 }
831 } 839 }
832 840
833 841
834 842
835 void* RegExpUnparser::VisitCharacterClass(RegExpCharacterClass* that, 843 void* RegExpUnparser::VisitCharacterClass(RegExpCharacterClass* that,
836 void* data) { 844 void* data) {
837 if (that->is_negated()) 845 if (that->is_negated())
838 stream()->Add("^"); 846 stream()->Add("^");
839 stream()->Add("["); 847 stream()->Add("[");
840 for (int i = 0; i < that->ranges()->length(); i++) { 848 for (int i = 0; i < that->ranges(zone_)->length(); i++) {
841 if (i > 0) stream()->Add(" "); 849 if (i > 0) stream()->Add(" ");
842 VisitCharacterRange(that->ranges()->at(i)); 850 VisitCharacterRange(that->ranges(zone_)->at(i));
843 } 851 }
844 stream()->Add("]"); 852 stream()->Add("]");
845 return NULL; 853 return NULL;
846 } 854 }
847 855
848 856
849 void* RegExpUnparser::VisitAssertion(RegExpAssertion* that, void* data) { 857 void* RegExpUnparser::VisitAssertion(RegExpAssertion* that, void* data) {
850 switch (that->type()) { 858 switch (that->type()) {
851 case RegExpAssertion::START_OF_INPUT: 859 case RegExpAssertion::START_OF_INPUT:
852 stream()->Add("@^i"); 860 stream()->Add("@^i");
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 return NULL; 942 return NULL;
935 } 943 }
936 944
937 945
938 void* RegExpUnparser::VisitEmpty(RegExpEmpty* that, void* data) { 946 void* RegExpUnparser::VisitEmpty(RegExpEmpty* that, void* data) {
939 stream()->Put('%'); 947 stream()->Put('%');
940 return NULL; 948 return NULL;
941 } 949 }
942 950
943 951
944 SmartArrayPointer<const char> RegExpTree::ToString() { 952 SmartArrayPointer<const char> RegExpTree::ToString(Zone* zone) {
945 RegExpUnparser unparser; 953 RegExpUnparser unparser(zone);
946 Accept(&unparser, NULL); 954 Accept(&unparser, NULL);
947 return unparser.ToString(); 955 return unparser.ToString();
948 } 956 }
949 957
950 958
951 RegExpDisjunction::RegExpDisjunction(ZoneList<RegExpTree*>* alternatives) 959 RegExpDisjunction::RegExpDisjunction(ZoneList<RegExpTree*>* alternatives)
952 : alternatives_(alternatives) { 960 : alternatives_(alternatives) {
953 ASSERT(alternatives->length() > 1); 961 ASSERT(alternatives->length() > 1);
954 RegExpTree* first_alternative = alternatives->at(0); 962 RegExpTree* first_alternative = alternatives->at(0);
955 min_match_ = first_alternative->min_match(); 963 min_match_ = first_alternative->min_match();
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1104 OS::SNPrintF(buffer, "%d", Smi::cast(*handle_)->value()); 1112 OS::SNPrintF(buffer, "%d", Smi::cast(*handle_)->value());
1105 str = arr; 1113 str = arr;
1106 } else { 1114 } else {
1107 str = DoubleToCString(handle_->Number(), buffer); 1115 str = DoubleToCString(handle_->Number(), buffer);
1108 } 1116 }
1109 return FACTORY->NewStringFromAscii(CStrVector(str)); 1117 return FACTORY->NewStringFromAscii(CStrVector(str));
1110 } 1118 }
1111 1119
1112 1120
1113 } } // namespace v8::internal 1121 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ast.h ('k') | src/compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698