Revision: 24396
Author: [email protected]
Date: Thu Oct 2 13:05:11 2014 UTC
Log: Removed the Isolate* field from literal nodes.
Again 50MB less peak memory usage in the bug mentioned below...
BUG=417697
LOG=y
[email protected]
Review URL: https://codereview.chromium.org/620113002
https://code.google.com/p/v8/source/detail?r=24396
Modified:
/branches/bleeding_edge/src/ast-value-factory.cc
/branches/bleeding_edge/src/ast-value-factory.h
/branches/bleeding_edge/src/ast.cc
/branches/bleeding_edge/src/ast.h
=======================================
--- /branches/bleeding_edge/src/ast-value-factory.cc Wed Sep 10 12:38:12
2014 UTC
+++ /branches/bleeding_edge/src/ast-value-factory.cc Thu Oct 2 13:05:11
2014 UTC
@@ -117,14 +117,15 @@
bool AstRawString::Compare(void* a, void* b) {
- AstRawString* string1 = reinterpret_cast<AstRawString*>(a);
- AstRawString* string2 = reinterpret_cast<AstRawString*>(b);
- if (string1->is_one_byte_ != string2->is_one_byte_) return false;
- if (string1->hash_ != string2->hash_) return false;
- int length = string1->literal_bytes_.length();
- if (string2->literal_bytes_.length() != length) return false;
- return memcmp(string1->literal_bytes_.start(),
- string2->literal_bytes_.start(), length) == 0;
+ return *static_cast<AstRawString*>(a) == *static_cast<AstRawString*>(b);
+}
+
+bool AstRawString::operator==(const AstRawString& rhs) const {
+ if (is_one_byte_ != rhs.is_one_byte_) return false;
+ if (hash_ != rhs.hash_) return false;
+ int len = literal_bytes_.length();
+ if (rhs.literal_bytes_.length() != len) return false;
+ return memcmp(literal_bytes_.start(), rhs.literal_bytes_.start(), len)
== 0;
}
=======================================
--- /branches/bleeding_edge/src/ast-value-factory.h Tue Sep 16 22:15:39
2014 UTC
+++ /branches/bleeding_edge/src/ast-value-factory.h Thu Oct 2 13:05:11
2014 UTC
@@ -94,6 +94,8 @@
}
static bool Compare(void* a, void* b);
+ bool operator==(const AstRawString& rhs) const;
+
private:
friend class AstValueFactory;
friend class AstRawStringInternalizationKey;
=======================================
--- /branches/bleeding_edge/src/ast.cc Thu Oct 2 11:52:54 2014 UTC
+++ /branches/bleeding_edge/src/ast.cc Thu Oct 2 13:05:11 2014 UTC
@@ -1126,20 +1126,19 @@
#undef DONT_CACHE_NODE
-Handle<String> Literal::ToString() {
- if (value_->IsString()) return value_->AsString()->string();
- DCHECK(value_->IsNumber());
- char arr[100];
- Vector<char> buffer(arr, arraysize(arr));
- const char* str;
- if (value()->IsSmi()) {
- // Optimization only, the heap number case would subsume this.
- SNPrintF(buffer, "%d", Smi::cast(*value())->value());
- str = arr;
- } else {
- str = DoubleToCString(value()->Number(), buffer);
- }
- return isolate_->factory()->NewStringFromAsciiChecked(str);
+uint32_t Literal::Hash() {
+ return raw_value()->IsString()
+ ? raw_value()->AsString()->hash()
+ : ComputeLongHash(double_to_uint64(raw_value()->AsNumber()));
+}
+
+
+// static
+bool Literal::Match(void* literal1, void* literal2) {
+ const AstValue* x = static_cast<Literal*>(literal1)->raw_value();
+ const AstValue* y = static_cast<Literal*>(literal2)->raw_value();
+ return (x->IsString() && y->IsString() && *x->AsString() ==
*y->AsString()) ||
+ (x->IsNumber() && y->IsNumber() && x->AsNumber() ==
y->AsNumber());
}
=======================================
--- /branches/bleeding_edge/src/ast.h Thu Oct 2 11:52:54 2014 UTC
+++ /branches/bleeding_edge/src/ast.h Thu Oct 2 13:05:11 2014 UTC
@@ -1385,28 +1385,17 @@
// Support for using Literal as a HashMap key. NOTE: Currently, this
works
// only for string and number literals!
- uint32_t Hash() { return ToString()->Hash(); }
-
- static bool Match(void* literal1, void* literal2) {
- Handle<String> s1 = static_cast<Literal*>(literal1)->ToString();
- Handle<String> s2 = static_cast<Literal*>(literal2)->ToString();
- return String::Equals(s1, s2);
- }
+ uint32_t Hash();
+ static bool Match(void* literal1, void* literal2);
TypeFeedbackId LiteralFeedbackId() const { return reuse(id()); }
protected:
Literal(Zone* zone, const AstValue* value, int position, IdGen* id_gen)
- : Expression(zone, position, id_gen),
- value_(value),
- isolate_(zone->isolate()) {}
+ : Expression(zone, position, id_gen), value_(value) {}
private:
- Handle<String> ToString();
-
const AstValue* value_;
- // TODO(dcarney): remove. this is only needed for Match and Hash.
- Isolate* isolate_;
};
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.