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

Unified Diff: src/globals.h

Issue 1144183004: [strong] Refactor ObjectStrength into a replacement for strong boolean args (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: cl feedback and rebase Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/factory.cc ('k') | src/hydrogen.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/globals.h
diff --git a/src/globals.h b/src/globals.h
index f01c10044e9815d02c861075058e399b5a4356a7..cde58c9d58ab78855bfce07b39a47041c27acd63 100644
--- a/src/globals.h
+++ b/src/globals.h
@@ -233,11 +233,6 @@ template <typename T, class P = FreeStoreAllocationPolicy> class List;
// -----------------------------------------------------------------------------
// Declarations for use in both the preparser and the rest of V8.
-enum ObjectStrength {
- WEAK,
- FIRM // strong object
-};
-
// The Strict Mode (ECMA-262 5th edition, 4.2.2).
enum LanguageMode {
@@ -297,8 +292,32 @@ inline LanguageMode construct_language_mode(bool strict_bit, bool strong_bit) {
}
-inline ObjectStrength strength(LanguageMode language_mode) {
- return is_strong(language_mode) ? FIRM : WEAK;
+// Strong mode behaviour must sometimes be signalled by a two valued enum where
+// caching is involved, to prevent sloppy and strict mode from being incorrectly
+// differentiated.
+enum class Strength : bool {
+ WEAK, // sloppy, strict behaviour
+ STRONG // strong behaviour
+};
+
+
+inline bool is_strong(Strength strength) {
+ return strength == Strength::STRONG;
+}
+
+
+inline std::ostream& operator<<(std::ostream& os, const Strength& strength) {
+ return os << (is_strong(strength) ? "strong" : "weak");
+}
+
+
+inline Strength strength(LanguageMode language_mode) {
+ return is_strong(language_mode) ? Strength::STRONG : Strength::WEAK;
+}
+
+
+inline size_t hash_value(Strength strength) {
+ return static_cast<size_t>(strength);
}
« no previous file with comments | « src/factory.cc ('k') | src/hydrogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698