Browse files

all: lint, use explicit constructors

  • Loading branch information...
1 parent 5b29588 commit b790b6104d79289cf88c91e981b20668987128a6 @indutny committed Nov 18, 2012
Showing with 3,909 additions and 1,718 deletions.
  1. +1 −0 .gitignore
  2. +29 −8 include/candor.h
  3. +48 −27 src/api.cc
  4. +24 −2 src/api.h
  5. +25 −3 src/assembler-inl.h
  6. +25 −3 src/assembler.h
  7. +45 −27 src/ast.h
  8. +30 −9 src/can.cc
  9. +45 −22 src/code-space.cc
  10. +28 −6 src/code-space.h
  11. +30 −8 src/cpu.cc
  12. +25 −3 src/cpu.h
  13. +28 −7 src/fullgen-inl.h
  14. +26 −4 src/fullgen-instructions-inl.h
  15. +24 −2 src/fullgen-instructions.cc
  16. +40 −16 src/fullgen-instructions.h
  17. +28 −6 src/fullgen.cc
  18. +33 −11 src/fullgen.h
  19. +64 −37 src/gc.cc
  20. +28 −6 src/gc.h
  21. +26 −4 src/heap-inl.h
  22. +134 −111 src/heap.cc
  23. +35 −13 src/heap.h
  24. +36 −14 src/hir-inl.h
  25. +31 −9 src/hir-instructions-inl.h
  26. +77 −55 src/hir-instructions.cc
  27. +42 −20 src/hir-instructions.h
  28. +27 −3 src/hir.cc
  29. +37 −14 src/hir.h
  30. +34 −12 src/ia32/assembler-ia32-inl.h
  31. +87 −64 src/ia32/assembler-ia32.cc
  32. +94 −73 src/ia32/assembler-ia32.h
  33. +26 −4 src/ia32/fullgen-ia32.cc
  34. +24 −2 src/ia32/lir-builder-ia32.cc
  35. +43 −20 src/ia32/lir-ia32.cc
  36. +25 −3 src/ia32/lir-ia32.h
  37. +34 −14 src/ia32/macroassembler-ia32.cc
  38. +27 −5 src/ia32/pic-ia32.cc
  39. +40 −18 src/ia32/stubs-ia32.cc
  40. +25 −3 src/ia32/stubs-ia32.h
  41. +45 −25 src/lexer.cc
  42. +28 −5 src/lexer.h
  43. +37 −13 src/lir-inl.h
  44. +29 −7 src/lir-instructions-inl.h
  45. +24 −2 src/lir-instructions.cc
  46. +59 −24 src/lir-instructions.h
  47. +35 −11 src/lir.cc
  48. +29 −7 src/lir.h
  49. +27 −5 src/list.h
  50. +31 −9 src/macroassembler-inl.h
  51. +25 −3 src/macroassembler.cc
  52. +34 −12 src/macroassembler.h
  53. +249 −225 src/parser.cc
  54. +29 −7 src/parser.h
  55. +32 −8 src/pic.cc
  56. +28 −7 src/pic.h
  57. +48 −26 src/root.cc
  58. +28 −6 src/root.h
  59. +285 −261 src/runtime.cc
  60. +31 −9 src/runtime.h
  61. +26 −3 src/scope.cc
  62. +43 −15 src/scope.h
  63. +29 −6 src/source-map.cc
  64. +27 −5 src/source-map.h
  65. +25 −3 src/splay-tree.h
  66. +36 −13 src/stubs.h
  67. +63 −51 src/utils.h
  68. +35 −13 src/visitor.cc
  69. +29 −5 src/visitor.h
  70. +38 −16 src/x64/assembler-x64-inl.h
  71. +97 −75 src/x64/assembler-x64.cc
  72. +120 −98 src/x64/assembler-x64.h
  73. +26 −4 src/x64/fullgen-x64.cc
  74. +24 −2 src/x64/lir-builder-x64.cc
  75. +43 −20 src/x64/lir-x64.cc
  76. +25 −3 src/x64/lir-x64.h
  77. +33 −13 src/x64/macroassembler-x64.cc
  78. +27 −5 src/x64/pic-x64.cc
  79. +34 −12 src/x64/stubs-x64.cc
  80. +25 −3 src/x64/stubs-x64.h
  81. +27 −4 src/zone.cc
  82. +32 −9 src/zone.h
  83. +382 −0 tools/presubmit.py
View
1 .gitignore
@@ -5,3 +5,4 @@
/build
/out
/test-runner
+.cpplint-cache
View
37 include/candor.h
@@ -1,8 +1,30 @@
+/**
+ * Copyright (c) 2012, Fedor Indutny.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
#ifndef _INCLUDE_CANDOR_H_
#define _INCLUDE_CANDOR_H_
-#include <stdint.h> // uint32_t
-#include <sys/types.h> // size_t
+#include <stdint.h> // uint32_t
+#include <sys/types.h> // size_t
namespace candor {
@@ -14,7 +36,7 @@ namespace internal {
class List;
class EmptyClass;
class HValueReference;
-} // namespace internal
+} // namespace internal
class Value;
class Nil;
@@ -48,7 +70,6 @@ class Isolate {
static void DisableLIRLogging();
protected:
-
void SetError(Error* err);
internal::Heap* heap;
@@ -232,7 +253,7 @@ template <class T>
class Handle {
public:
Handle();
- Handle(Value* v);
+ explicit Handle(Value* v);
~Handle();
void Wrap(Value* v);
@@ -263,7 +284,7 @@ class Handle {
class CWrapper {
public:
- CWrapper(const int* magic);
+ explicit CWrapper(const int* magic);
virtual ~CWrapper();
inline CData* Wrap() { return ref->As<CData>(); }
@@ -295,6 +316,6 @@ class CWrapper {
Handle<CData> ref;
};
-} // namespace candor
+} // namespace candor
-#endif // _INCLUDE_CANDOR_H_
+#endif // _INCLUDE_CANDOR_H_
View
75 src/api.cc
@@ -1,3 +1,30 @@
+/**
+ * Copyright (c) 2012, Fedor Indutny.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <stdio.h> // fprintf
+#include <stdint.h> // uint32_t
+#include <string.h> // strlen
+#include <stdlib.h> // NULL
+
#include "candor.h"
#include "heap.h"
#include "heap-inl.h"
@@ -11,11 +38,6 @@
#include "runtime.h"
#include "utils.h"
-#include <stdio.h> // fprintf
-#include <stdint.h> // uint32_t
-#include <string.h> // strlen
-#include <stdlib.h> // NULL
-
namespace candor {
using namespace internal;
@@ -70,7 +92,7 @@ Isolate::~Isolate() {
Isolate* ISOLATE {
- // TODO: Support multiple isolates
+ // TODO(indutny): Support multiple isolates
return current_isolate;
}
@@ -237,15 +259,15 @@ bool Value::Is() {
Heap::HeapTag tag = Heap::kTagNil;
switch (T::tag) {
- case kNil: tag = Heap::kTagNil; break;
- case kNumber: tag = Heap::kTagNumber; break;
- case kBoolean: tag = Heap::kTagBoolean; break;
- case kString: tag = Heap::kTagString; break;
- case kFunction: tag = Heap::kTagFunction; break;
- case kObject: tag = Heap::kTagObject; break;
- case kArray: tag = Heap::kTagArray; break;
- case kCData: tag = Heap::kTagCData; break;
- default: return false;
+ case kNil: tag = Heap::kTagNil; break;
+ case kNumber: tag = Heap::kTagNumber; break;
+ case kBoolean: tag = Heap::kTagBoolean; break;
+ case kString: tag = Heap::kTagString; break;
+ case kFunction: tag = Heap::kTagFunction; break;
+ case kObject: tag = Heap::kTagObject; break;
+ case kArray: tag = Heap::kTagArray; break;
+ case kCData: tag = Heap::kTagCData; break;
+ default: return false;
}
if (addr() != NULL && addr() != HNil::New()) {
@@ -259,15 +281,15 @@ bool Value::Is() {
Value::ValueType Value::Type() {
switch (HValue::GetTag(addr())) {
- case Heap::kTagNil: return kNil;
- case Heap::kTagNumber: return kNumber;
- case Heap::kTagBoolean: return kBoolean;
- case Heap::kTagString: return kString;
- case Heap::kTagFunction: return kFunction;
- case Heap::kTagObject: return kObject;
- case Heap::kTagArray: return kArray;
- case Heap::kTagCData: return kCData;
- default: return kNone;
+ case Heap::kTagNil: return kNil;
+ case Heap::kTagNumber: return kNumber;
+ case Heap::kTagBoolean: return kBoolean;
+ case Heap::kTagString: return kString;
+ case Heap::kTagFunction: return kFunction;
+ case Heap::kTagObject: return kObject;
+ case Heap::kTagArray: return kArray;
+ case Heap::kTagCData: return kCData;
+ default: return kNone;
}
}
@@ -540,7 +562,7 @@ void* CData::GetContents() {
CWrapper::CWrapper(const int* magic) : isolate(ISOLATE), magic_(magic) {
- CData* data = CData::New(sizeof(void*));
+ CData* data = CData::New(sizeof(this));
// Save pointer of class
*reinterpret_cast<CWrapper**>(data->GetContents()) = this;
@@ -583,5 +605,4 @@ void CWrapper::WeakCallback(Value* data) {
delete wrapper;
}
-
-} // namespace candor
+} // namespace candor
View
26 src/api.h
@@ -1,7 +1,29 @@
+/**
+ * Copyright (c) 2012, Fedor Indutny.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
#ifndef _SRC_API_H_
#define _SRC_API_H_
namespace candor {
-} // namespace candor
+} // namespace candor
-#endif // _SRC_API_H_
+#endif // _SRC_API_H_
View
28 src/assembler-inl.h
@@ -1,3 +1,25 @@
+/**
+ * Copyright (c) 2012, Fedor Indutny.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
#ifndef _SRC_ASSEMBLER_INL_H_
#define _SRC_ASSEMBLER_INL_H_
@@ -34,7 +56,7 @@ inline void Label::use(Assembler* a, uint32_t offset) {
AddUse(a, info);
}
-} // namespace internal
-} // namespace candor
+} // namespace internal
+} // namespace candor
-#endif // _SRC_ASSEMBLER_INL_H_
+#endif // _SRC_ASSEMBLER_INL_H_
View
28 src/assembler.h
@@ -1,3 +1,25 @@
+/**
+ * Copyright (c) 2012, Fedor Indutny.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
#ifndef _SRC_ASSEMBLER_H_
#define _SRC_ASSEMBLER_H_
@@ -31,7 +53,7 @@ class Label : public ZoneObject {
friend class Assembler;
};
-} // namespace internal
-} // namespace candor
+} // namespace internal
+} // namespace candor
-#endif // _SRC_ASSEMBLER_H_
+#endif // _SRC_ASSEMBLER_H_
View
72 src/ast.h
@@ -1,12 +1,34 @@
+/**
+ * Copyright (c) 2012, Fedor Indutny.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
#ifndef _SRC_AST_H_
#define _SRC_AST_H_
-#include "zone.h" // ZoneObject
-#include "utils.h" // List
-#include "lexer.h" // lexer
-#include "scope.h" // Scope
+#include <assert.h> // assert
-#include <assert.h> // assert
+#include "zone.h" // ZoneObject
+#include "utils.h" // List
+#include "lexer.h" // lexer
+#include "scope.h" // Scope
namespace candor {
namespace internal {
@@ -57,7 +79,6 @@ typedef ZoneList<AstNode*> AstList;
class AstNode : public ZoneObject {
public:
enum Type {
-
#define MAP_DF(x) x,
TYPE_MAPPING_NORMAL(MAP_DF)
TYPE_MAPPING_LEXER(MAP_DF)
@@ -66,14 +87,14 @@ class AstNode : public ZoneObject {
kNop
};
- AstNode(Type type) : id(-1),
- type_(type),
- value_(NULL),
- offset_(-1),
- length_(0),
- stack_count_(0),
- context_count_(0),
- root_(false) {
+ explicit AstNode(Type type) : id(-1),
+ type_(type),
+ value_(NULL),
+ offset_(-1),
+ length_(0),
+ stack_count_(0),
+ context_count_(0),
+ root_(false) {
}
AstNode(Type type, Lexer::Token* token) : type_(type),
@@ -103,8 +124,8 @@ class AstNode : public ZoneObject {
#define MAP_DF(x) case Lexer::x: return x;
TYPE_MAPPING_LEXER(MAP_DF)
#undef MAP_DF
- default:
- return kNop;
+ default:
+ return kNop;
}
}
@@ -169,8 +190,7 @@ class AstNode : public ZoneObject {
is(kContinue) || is(kReturn) || is(kIf) ?
p->Print("[")
:
- p->Print("[%s ", strtype)
- ) &&
+ p->Print("[%s ", strtype)) &&
(length_ == 0 ||
(p->PrintValue(value(), length()) &&
@@ -443,7 +463,7 @@ class ObjectLiteral : public AstNode {
// contains name and variables list
class FunctionLiteral : public AstNode {
public:
- FunctionLiteral(AstNode* variable) : AstNode(kFunction) {
+ explicit FunctionLiteral(AstNode* variable) : AstNode(kFunction) {
if (variable != NULL) {
offset(variable->offset());
length(variable->length());
@@ -503,8 +523,7 @@ class FunctionLiteral : public AstNode {
(variable() == NULL ?
p->Print("(anonymous)")
:
- variable()->Print(p)
- ) &&
+ variable()->Print(p)) &&
p->Print(" @[") &&
PrintChildren(p, args()) &&
p->Print("] ") &&
@@ -547,7 +566,7 @@ class AstValue : public AstNode {
name_(name) {
}
- AstValue(AstValueType type) : AstNode(kValue), type_(type) {
+ explicit AstValue(AstValueType type) : AstNode(kValue), type_(type) {
}
static inline AstValue* Cast(AstNode* node) {
@@ -563,8 +582,7 @@ class AstValue : public AstNode {
(slot()->is_context() ?
p->Print(" @context[%d]:%d", slot()->depth(), slot()->index())
:
- p->Print(" @stack:%d", slot()->index())
- ) &&
+ p->Print(" @stack:%d", slot()->index())) &&
p->Print("]");
}
@@ -581,7 +599,7 @@ class AstValue : public AstNode {
AstNode* name_;
};
-} // namespace internal
-} // namespace candor
+} // namespace internal
+} // namespace candor
-#endif // _SRC_AST_H_
+#endif // _SRC_AST_H_
View
39 src/can.cc
@@ -1,12 +1,34 @@
-#include "candor.h"
-#include "utils.h" // candor::internal::List
+/**
+ * Copyright (c) 2012, Fedor Indutny.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <stdio.h> // fprintf
+#include <stdlib.h> // abort
+#include <unistd.h> // open, lseek
+#include <fcntl.h> // O_RDONLY, ...
+#include <sys/types.h> // off_t
+#include <string.h> // memcpy
-#include <stdio.h> // fprintf
-#include <stdlib.h> // abort
-#include <unistd.h> // open, lseek
-#include <fcntl.h> // O_RDONLY, ...
-#include <sys/types.h> // off_t
-#include <string.h> // memcpy
+#include "candor.h"
+#include "utils.h" // candor::internal::List
typedef candor::internal::List<char*, candor::internal::EmptyClass> List;
@@ -170,7 +192,6 @@ void StartRepl() {
strlen(prepended));
if (!multiline || strlen(cmd) != 0) {
-
// Continue collecting string on syntax error
if (isolate.HasError()) {
delete prepended;
View
67 src/code-space.cc
@@ -1,24 +1,47 @@
+/**
+ * Copyright (c) 2012, Fedor Indutny.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
#include "code-space.h"
-#include "candor.h" // Error
-#include "heap.h" // Heap
-#include "heap-inl.h" // Heap
-#include "parser.h" // Parser
-#include "scope.h" // Scope
-#include "macroassembler.h" // Masm
-#include "fullgen.h" // Fullgen
-#include "fullgen-inl.h" // Fullgen
-#include "hir.h" // HIR
-#include "hir-inl.h" // HIR
-#include "lir.h" // LIR
-#include "lir-inl.h" // LIR
-#include "source-map.h" // SourceMap
-#include "stubs.h" // EntryStub
-#include "pic.h" // PIC
-#include "utils.h" // GetPageSize
-
-#include <stdlib.h> // NULL
-#include <string.h> // memcpy, memset
-#include <sys/mman.h> // mmap
+
+#include <stdlib.h> // NULL
+#include <string.h> // memcpy, memset
+#include <sys/mman.h> // mmap
+
+#include "candor.h" // Error
+#include "heap.h" // Heap
+#include "heap-inl.h" // Heap
+#include "parser.h" // Parser
+#include "scope.h" // Scope
+#include "macroassembler.h" // Masm
+#include "fullgen.h" // Fullgen
+#include "fullgen-inl.h" // Fullgen
+#include "hir.h" // HIR
+#include "hir-inl.h" // HIR
+#include "lir.h" // LIR
+#include "lir-inl.h" // LIR
+#include "source-map.h" // SourceMap
+#include "stubs.h" // EntryStub
+#include "pic.h" // PIC
+#include "utils.h" // GetPageSize
namespace candor {
namespace internal {
@@ -292,5 +315,5 @@ void CodeChunk::Unref() {
assert(ref_ >= 0);
}
-} // namespace internal
-} // namespace candor
+} // namespace internal
+} // namespace candor
View
34 src/code-space.h
@@ -1,7 +1,29 @@
+/**
+ * Copyright (c) 2012, Fedor Indutny.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
#ifndef _SRC_CODE_SPACE_H_
#define _SRC_CODE_SPACE_H_
-#include "utils.h" // List
+#include "utils.h" // List
namespace candor {
@@ -27,7 +49,7 @@ class CodeSpace {
public:
typedef Value* (*Code)(char*, uint32_t, Value* []);
- CodeSpace(Heap* heap);
+ explicit CodeSpace(Heap* heap);
~CodeSpace();
void CollectGarbage();
@@ -62,7 +84,7 @@ class CodeSpace {
class CodePage {
public:
- CodePage(uint32_t size);
+ explicit CodePage(uint32_t size);
~CodePage();
bool Has(uint32_t size);
@@ -106,7 +128,7 @@ class CodeChunk {
friend class CodeSpace;
};
-} // internal
-} // candor
+} // internal
+} // candor
-#endif // _SRC_CODE_SPACE_H_
+#endif // _SRC_CODE_SPACE_H_
View
38 src/cpu.cc
@@ -1,14 +1,36 @@
+/**
+ * Copyright (c) 2012, Fedor Indutny.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
#include "cpu.h"
-#include "zone.h" // Zone
-#include "code-space.h" // CodeSpace
+#include <stdint.h> // uint32_t
+#include <unistd.h> // intptr_t
+#include <string.h> // memcpy
+
+#include "zone.h" // Zone
+#include "code-space.h" // CodeSpace
#include "macroassembler.h"
#include "macroassembler-inl.h"
-#include <stdint.h> // uint32_t
-#include <unistd.h> // intptr_t
-#include <string.h> // memcpy
-
namespace candor {
namespace internal {
@@ -37,5 +59,5 @@ void CPU::Probe() {
probed_ = true;
}
-} // internal
-} // candor
+} // internal
+} // candor
View
28 src/cpu.h
@@ -1,3 +1,25 @@
+/**
+ * Copyright (c) 2012, Fedor Indutny.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
#ifndef _SRC_CPU_H_
#define _SRC_CPU_H_
@@ -20,7 +42,7 @@ class CPU {
}
};
-} // namespace internal
-} // namespace candor
+} // namespace internal
+} // namespace candor
-#endif // _SRC_CPU_H_
+#endif // _SRC_CPU_H_
View
35 src/fullgen-inl.h
@@ -1,19 +1,40 @@
+/**
+ * Copyright (c) 2012, Fedor Indutny.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
#ifndef _SRC_FULLGEN_INL_H_
#define _SRC_FULLGEN_INL_H_
#ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS
-#endif // _STDC_FORMAT_MACROS
+#endif // _STDC_FORMAT_MACROS
-#include <inttypes.h> // PRIu64
+#include <inttypes.h> // PRIu64
+#include <assert.h>
#include "fullgen.h"
#include "fullgen-instructions.h"
#include "fullgen-instructions-inl.h"
#include "heap.h"
-#include <assert.h>
-
namespace candor {
namespace internal {
@@ -157,7 +178,7 @@ inline FOperand* FScopedSlot::operand() {
return operand_;
}
-} // namespace internal
-} // namespace candor
+} // namespace internal
+} // namespace candor
-#endif // _SRC_FULLGEN_INL_H_
+#endif // _SRC_FULLGEN_INL_H_
View
30 src/fullgen-instructions-inl.h
@@ -1,10 +1,32 @@
+/**
+ * Copyright (c) 2012, Fedor Indutny.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
#ifndef _SRC_FULLGEN_INSTRUCTION_INL_H_
#define _SRC_FULLGEN_INSTRUCTION_INL_H_
#include "fullgen.h"
#include "fullgen-inl.h"
#include "fullgen-instructions.h"
-#include <assert.h> // assert
+#include <assert.h> // assert
namespace candor {
namespace internal {
@@ -66,7 +88,7 @@ inline void FEntry::stack_slots(int stack_slots) {
stack_slots_ = stack_slots;
}
-} // namespace internal
-} // namespace candor
+} // namespace internal
+} // namespace candor
-#endif // _SRC_FULLGEN_INSTRUCTION_INL_H_
+#endif // _SRC_FULLGEN_INSTRUCTION_INL_H_
View
26 src/fullgen-instructions.cc
@@ -1,3 +1,25 @@
+/**
+ * Copyright (c) 2012, Fedor Indutny.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
#include "fullgen.h"
#include "fullgen-inl.h"
#include "fullgen-instructions.h"
@@ -64,5 +86,5 @@ void FIf::Print(PrintBuffer* p) {
p->Print(") => %d Else %d\n", t_->id, f_->id);
}
-} // internal
-} // candor
+} // internal
+} // candor
View
56 src/fullgen-instructions.h
@@ -1,7 +1,29 @@
+/**
+ * Copyright (c) 2012, Fedor Indutny.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
#ifndef _SRC_FULLGEN_INSTRUCTIONS_H
#define _SRC_FULLGEN_INSTRUCTIONS_H
-#include "ast.h" // AstNode
+#include "ast.h" // AstNode
#include "macroassembler.h"
#include "zone.h"
#include "utils.h"
@@ -64,7 +86,7 @@ class FInstruction : public ZoneObject {
kNone
};
- FInstruction(Type type);
+ explicit FInstruction(Type type);
static inline const char* TypeToStr(Type type);
inline FInstruction* SetResult(FOperand* op);
@@ -125,8 +147,8 @@ class FLabel : public FInstruction {
class FEntry : public FInstruction {
public:
- FEntry(int context_slots) : FInstruction(kEntry),
- context_slots_(context_slots) {
+ explicit FEntry(int context_slots) : FInstruction(kEntry),
+ context_slots_(context_slots) {
}
inline int stack_slots();
@@ -182,8 +204,8 @@ class FLiteral : public FInstruction {
class FBinOp : public FInstruction {
public:
- FBinOp(BinOp::BinOpType sub_type) : FInstruction(kBinOp),
- sub_type_(sub_type) {
+ explicit FBinOp(BinOp::BinOpType sub_type) : FInstruction(kBinOp),
+ sub_type_(sub_type) {
}
FULLGEN_DEFAULT_METHODS(BinOp)
@@ -258,8 +280,9 @@ class FDeleteProperty : public FInstruction {
class FAllocateObject : public FInstruction {
public:
- FAllocateObject(int size) : FInstruction(kAllocateObject),
- size_(RoundUp(PowerOfTwo(size + 1), 64)) {
+ explicit FAllocateObject(int size)
+ : FInstruction(kAllocateObject),
+ size_(RoundUp(PowerOfTwo(size + 1), 64)) {
}
FULLGEN_DEFAULT_METHODS(AllocateObject)
@@ -270,8 +293,9 @@ class FAllocateObject : public FInstruction {
class FAllocateArray : public FInstruction {
public:
- FAllocateArray(int size) : FInstruction(kAllocateArray),
- size_(RoundUp(PowerOfTwo(size + 1), 64)) {
+ explicit FAllocateArray(int size)
+ : FInstruction(kAllocateArray),
+ size_(RoundUp(PowerOfTwo(size + 1), 64)) {
}
FULLGEN_DEFAULT_METHODS(AllocateArray)
@@ -322,7 +346,7 @@ class FKeysof : public FInstruction {
class FBreak : public FInstruction {
public:
- FBreak(FLabel* label) : FInstruction(kBreak), label_(label) {
+ explicit FBreak(FLabel* label) : FInstruction(kBreak), label_(label) {
}
void Print(PrintBuffer* p);
@@ -334,7 +358,7 @@ class FBreak : public FInstruction {
class FContinue : public FInstruction {
public:
- FContinue(FLabel* label) : FInstruction(kContinue), label_(label) {
+ explicit FContinue(FLabel* label) : FInstruction(kContinue), label_(label) {
}
void Print(PrintBuffer* p);
@@ -359,7 +383,7 @@ class FIf : public FInstruction {
class FGoto : public FInstruction {
public:
- FGoto(FLabel* label) : FInstruction(kGoto), label_(label) {
+ explicit FGoto(FLabel* label) : FInstruction(kGoto), label_(label) {
}
void Print(PrintBuffer* p);
@@ -443,7 +467,7 @@ class FCall : public FInstruction {
#undef FULLGEN_DEFAULT_METHODS
-} // internal
-} // candor
+} // internal
+} // candor
-#endif // _SRC_FULLGEN_INSTRUCTIONS_H
+#endif // _SRC_FULLGEN_INSTRUCTIONS_H
View
34 src/fullgen.cc
@@ -1,10 +1,32 @@
+/**
+ * Copyright (c) 2012, Fedor Indutny.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
#include "fullgen.h"
#include "fullgen-inl.h"
#include "fullgen-instructions.h"
#include "fullgen-instructions-inl.h"
#include "heap.h"
#include "heap-inl.h"
-#include "scope.h" // ScopeSlot
+#include "scope.h" // ScopeSlot
#include "macroassembler.h"
namespace candor {
@@ -801,11 +823,11 @@ FScopedSlot::~FScopedSlot() {
void FOperand::Print(PrintBuffer* p) {
switch (type_) {
- case kStack: p->Print("s[%d]", index_); break;
- case kContext: p->Print("c[%d:%d]", index_, depth_); break;
- default: UNEXPECTED
+ case kStack: p->Print("s[%d]", index_); break;
+ case kContext: p->Print("c[%d:%d]", index_, depth_); break;
+ default: UNEXPECTED
}
}
-} // namespace internal
-} // namespace candor
+} // namespace internal
+} // namespace candor
View
44 src/fullgen.h
@@ -1,14 +1,36 @@
+/**
+ * Copyright (c) 2012, Fedor Indutny.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
#ifndef _SRC_FULLGEN_H_
#define _SRC_FULLGEN_H_
+#include <assert.h> // assert
+#include <stdint.h> // uint32_t
+
#include "visitor.h"
#include "root.h"
-#include "ast.h" // AstNode, FunctionLiteral
-#include "zone.h" // ZoneObject
-#include "utils.h" // List
-
-#include <assert.h> // assert
-#include <stdint.h> // uint32_t
+#include "ast.h" // AstNode, FunctionLiteral
+#include "zone.h" // ZoneObject
+#include "utils.h" // List
namespace candor {
namespace internal {
@@ -56,7 +78,7 @@ class FOperand : public ZoneObject {
class FStackSlot : public FOperand {
public:
- FStackSlot(int index) : FOperand(kStack, index, -1) {
+ explicit FStackSlot(int index) : FOperand(kStack, index, -1) {
}
};
@@ -68,7 +90,7 @@ class FContextSlot : public FOperand {
class FScopedSlot {
public:
- FScopedSlot(Fullgen* f);
+ explicit FScopedSlot(Fullgen* f);
~FScopedSlot();
inline FOperand* operand();
@@ -170,7 +192,7 @@ class Fullgen : public Visitor<FInstruction> {
friend class FScopedSlot;
};
-} // namespace internal
-} // namespace candor
+} // namespace internal
+} // namespace candor
-#endif // _SRC_FULLGEN_H_
+#endif // _SRC_FULLGEN_H_
View
101 src/gc.cc
@@ -1,13 +1,36 @@
+/**
+ * Copyright (c) 2012, Fedor Indutny.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
#include "gc.h"
+
+#include <stdlib.h> // NULL
+#include <stdint.h> // int32_t and others
+#include <unistd.h> // intptr_t
+#include <assert.h> // assert
+
#include "heap.h"
#include "heap-inl.h"
#include "code-space.h"
-#include <stdlib.h> // NULL
-#include <stdint.h> // int32_t and others
-#include <unistd.h> // intptr_t
-#include <assert.h> // assert
-
namespace candor {
namespace internal {
@@ -29,11 +52,11 @@ void GC::CollectGarbage(char* stack_top) {
}
switch (heap()->needs_gc()) {
- case Heap::kGCNewSpace: gc_type(kNewSpace); break;
- case Heap::kGCOldSpace: gc_type(kOldSpace); break;
- default:
- UNEXPECTED
- break;
+ case Heap::kGCNewSpace: gc_type(kNewSpace); break;
+ case Heap::kGCOldSpace: gc_type(kOldSpace); break;
+ default:
+ UNEXPECTED
+ break;
}
// Select space to GC
@@ -234,31 +257,35 @@ bool GC::IsInCurrentSpace(HValue* value) {
void GC::VisitValue(HValue* value) {
switch (value->tag()) {
- case Heap::kTagContext:
- return VisitContext(value->As<HContext>());
- case Heap::kTagFunction:
- return VisitFunction(value->As<HFunction>());
- case Heap::kTagObject:
- return VisitObject(value->As<HObject>());
- case Heap::kTagArray:
- return VisitArray(value->As<HArray>());
- case Heap::kTagMap:
- return VisitMap(value->As<HMap>());
-
- // non-cons strings and numbers ain't referencing anyone
- case Heap::kTagString:
- switch (HValue::GetRepresentation<HString::Representation>(value->addr())) {
- case HString::kNormal:
- break;
- case HString::kCons:
- return VisitString(value);
- }
- case Heap::kTagNumber:
- case Heap::kTagBoolean:
- case Heap::kTagCData:
- return;
- default:
- UNEXPECTED
+ case Heap::kTagContext:
+ return VisitContext(value->As<HContext>());
+ case Heap::kTagFunction:
+ return VisitFunction(value->As<HFunction>());
+ case Heap::kTagObject:
+ return VisitObject(value->As<HObject>());
+ case Heap::kTagArray:
+ return VisitArray(value->As<HArray>());
+ case Heap::kTagMap:
+ return VisitMap(value->As<HMap>());
+
+ // non-cons strings and numbers ain't referencing anyone
+ case Heap::kTagString:
+ {
+ HString::Representation r;
+ r = HValue::GetRepresentation<HString::Representation>(value->addr());
+ switch (r) {
+ case HString::kNormal:
+ break;
+ case HString::kCons:
+ return VisitString(value);
+ }
+ }
+ case Heap::kTagNumber:
+ case Heap::kTagBoolean:
+ case Heap::kTagCData:
+ return;
+ default:
+ UNEXPECTED
}
}
@@ -319,5 +346,5 @@ void GC::VisitString(HValue* value) {
HString::RightConsSlot(value->addr()));
}
-} // namespace internal
-} // namespace candor
+} // namespace internal
+} // namespace candor
View
34 src/gc.h
@@ -1,8 +1,30 @@
+/**
+ * Copyright (c) 2012, Fedor Indutny.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
#ifndef _SRC_GC_H_
#define _SRC_GC_H_
-#include "zone.h" // ZoneObject
-#include "utils.h" // List
+#include "zone.h" // ZoneObject
+#include "utils.h" // List
namespace candor {
namespace internal {
@@ -41,7 +63,7 @@ class GC {
typedef ZoneList<GCValue*> GCList;
- GC(Heap* heap) : heap_(heap), gc_type_(kNone) {
+ explicit GC(Heap* heap) : heap_(heap), gc_type_(kNone) {
}
void CollectGarbage(char* stack_top);
@@ -92,7 +114,7 @@ class GC {
GCType gc_type_;
};
-} // namespace internal
-} // namespace candor
+} // namespace internal
+} // namespace candor
-#endif // _SRC_GC_H_
+#endif // _SRC_GC_H_
View
30 src/heap-inl.h
@@ -1,7 +1,29 @@
+/**
+ * Copyright (c) 2012, Fedor Indutny.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
#ifndef _SRC_HEAP_INL_H_
#define _SRC_HEAP_INL_H_
-#include <stdint.h> // int64_t, intptr_t
+#include <stdint.h> // int64_t, intptr_t
namespace candor {
namespace internal {
@@ -174,7 +196,7 @@ inline void HFunction::SetContext(char* addr, char* context) {
*root_slot = context;
}
-} // namespace internal
-} // namespace candor
+} // namespace internal
+} // namespace candor
-#endif // _SRC_HEAP_INL_H_
+#endif // _SRC_HEAP_INL_H_
View
245 src/heap.cc
@@ -1,12 +1,35 @@
+/**
+ * Copyright (c) 2012, Fedor Indutny.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
#include "heap.h"
-#include "heap-inl.h"
-#include "runtime.h" // RuntimeLookupProperty
-#include <stdint.h> // uint32_t, intptr_t
-#include <stdlib.h> // NULL
-#include <string.h> // memcpy
-#include <zone.h> // Zone::Allocate
-#include <assert.h> // assert
+#include <stdint.h> // uint32_t, intptr_t
+#include <stdlib.h> // NULL
+#include <string.h> // memcpy
+#include <zone.h> // Zone::Allocate
+#include <assert.h> // assert
+
+#include "heap-inl.h"
+#include "runtime.h" // RuntimeLookupProperty
namespace candor {
namespace internal {
@@ -143,14 +166,14 @@ char* Heap::CreateBoolean(bool value) {
const char* Heap::ErrorToString(Error err) {
switch (err) {
- case kErrorNone:
- return NULL;
- case kErrorIncorrectLhs:
- return "Incorrect left-hand side";
- case kErrorCallWithoutVariable:
- return "Call without variable";
- case kErrorExpectedLoop:
- return "Expected loop";
+ case kErrorNone:
+ return NULL;
+ case kErrorIncorrectLhs:
+ return "Incorrect left-hand side";
+ case kErrorCallWithoutVariable:
+ return "Call without variable";
+ case kErrorExpectedLoop:
+ return "Expected loop";
}
return NULL;
@@ -202,55 +225,55 @@ HValue* HValue::CopyTo(Space* old_space, Space* new_space) {
uint32_t size = kPointerSize;
switch (tag()) {
- case Heap::kTagContext:
- // parent + slots
- size += (2 + As<HContext>()->slots()) * kPointerSize;
- break;
- case Heap::kTagFunction:
- // parent + body + root + argc
- size += 4 * kPointerSize;
- break;
- case Heap::kTagNumber:
- size += sizeof(double);
- break;
- case Heap::kTagBoolean:
- size += kPointerSize;
- break;
- case Heap::kTagString:
- // hash + length
- size += 2 * kPointerSize;
- switch (GetRepresentation<HString::Representation>(addr())) {
- case HString::kNormal:
- // + bytes
- size += As<HString>()->length();
+ case Heap::kTagContext:
+ // parent + slots
+ size += (2 + As<HContext>()->slots()) * kPointerSize;
+ break;
+ case Heap::kTagFunction:
+ // parent + body + root + argc
+ size += 4 * kPointerSize;
+ break;
+ case Heap::kTagNumber:
+ size += sizeof(double);
break;
- case HString::kCons:
- // + lhs + rhs + scratch_slot (for traversing)
+ case Heap::kTagBoolean:
+ size += kPointerSize;
+ break;
+ case Heap::kTagString:
+ // hash + length
size += 2 * kPointerSize;
+ switch (GetRepresentation<HString::Representation>(addr())) {
+ case HString::kNormal:
+ // + bytes
+ size += As<HString>()->length();
+ break;
+ case HString::kCons:
+ // + lhs + rhs + scratch_slot (for traversing)
+ size += 2 * kPointerSize;
+ break;
+ default:
+ UNEXPECTED
+ break;
+ }
break;
- default:
- UNEXPECTED
+ case Heap::kTagObject:
+ // mask + map + proto
+ size += 3 * kPointerSize;
break;
- }
- break;
- case Heap::kTagObject:
- // mask + map + proto
- size += 3 * kPointerSize;
- break;
- case Heap::kTagArray:
- // mask + map + proto + length
- size += 4 * kPointerSize;
- break;
- case Heap::kTagMap:
- // size + space ( keys + values )
- size += (1 + (As<HMap>()->size() << 1)) * kPointerSize;
- break;
- case Heap::kTagCData:
- // size + data
- size += kPointerSize + As<HCData>()->size();
- break;
- default:
- UNEXPECTED
+ case Heap::kTagArray:
+ // mask + map + proto + length
+ size += 4 * kPointerSize;
+ break;
+ case Heap::kTagMap:
+ // size + space ( keys + values )
+ size += (1 + (As<HMap>()->size() << 1)) * kPointerSize;
+ break;
+ case Heap::kTagCData:
+ // size + data
+ size += kPointerSize + As<HCData>()->size();
+ break;
+ default:
+ UNEXPECTED
}
IncrementGeneration();
@@ -283,7 +306,7 @@ char* HContext::New(Heap* heap,
char** slot = reinterpret_cast<char**>(result + GetIndexDisp(0));
while (values->length() != 0) {
*slot = values->Shift();
- slot ++;
+ slot++;
}
return result;
@@ -363,34 +386,34 @@ char* HString::NewCons(Heap* heap,
char* HString::FlattenCons(char* addr, char* buffer) {
while (addr != NULL) {
switch (GetRepresentation<Representation>(addr)) {
- case kNormal:
- {
- uint32_t len = HString::Length(addr);
- memcpy(buffer, addr + kValueOffset, len);
- return buffer + len;
- }
- case kCons:
- {
- char* left = LeftCons(addr);
- char* right = RightCons(addr);
-
- if (right == HNil::New()) {
- addr = left;
- } else {
- // Iterate through bigger string, recurse through smaller
- if (HString::Length(left) > HString::Length(right)) {
- FlattenCons(right, buffer + HString::Length(left));
+ case kNormal:
+ {
+ uint32_t len = HString::Length(addr);
+ memcpy(buffer, addr + kValueOffset, len);
+ return buffer + len;
+ }
+ case kCons:
+ {
+ char* left = LeftCons(addr);
+ char* right = RightCons(addr);
+
+ if (right == HNil::New()) {
addr = left;
} else {
- buffer = FlattenCons(left, buffer);
- addr = right;
+ // Iterate through bigger string, recurse through smaller
+ if (HString::Length(left) > HString::Length(right)) {
+ FlattenCons(right, buffer + HString::Length(left));
+ addr = left;
+ } else {
+ buffer = FlattenCons(left, buffer);
+ addr = right;
+ }
}
}
- }
- break;
- default:
- UNEXPECTED
- return buffer;
+ break;
+ default:
+ UNEXPECTED
+ return buffer;
}
}
@@ -400,30 +423,30 @@ char* HString::FlattenCons(char* addr, char* buffer) {
char* HString::Value(Heap* heap, char* addr) {
switch (GetRepresentation<Representation>(addr)) {
- case kNormal:
- return addr + kValueOffset;
- case kCons:
- if (RightCons(addr) == HNil::New()) {
- // Return cached left if right is null
- return HString::Value(heap, LeftCons(addr));
- } else {
- // Concatenate strings and put them into left slot
- char* result = HString::New(heap,
- Heap::kTenureNew,
- HString::Length(addr));
- char* value = HString::Value(heap, result);
-
- // Traverse cons tree and put strings in
- HString::FlattenCons(addr, value);
-
- *RightConsSlot(addr) = HNil::New();
- *LeftConsSlot(addr) = result;
-
- return value;
- }
- default:
- UNEXPECTED
- return NULL;
+ case kNormal:
+ return addr + kValueOffset;
+ case kCons:
+ if (RightCons(addr) == HNil::New()) {
+ // Return cached left if right is null
+ return HString::Value(heap, LeftCons(addr));
+ } else {
+ // Concatenate strings and put them into left slot
+ char* result = HString::New(heap,
+ Heap::kTenureNew,
+ HString::Length(addr));
+ char* value = HString::Value(heap, result);
+
+ // Traverse cons tree and put strings in
+ HString::FlattenCons(addr, value);
+
+ *RightConsSlot(addr) = HNil::New();
+ *LeftConsSlot(addr) = result;
+
+ return value;
+ }
+ default:
+ UNEXPECTED
+ return NULL;
}
}
@@ -568,5 +591,5 @@ char* HCData::New(Heap* heap, size_t size) {
return d;
}
-} // namespace internal
-} // namespace candor
+} // namespace internal
+} // namespace candor
View
48 src/heap.h
@@ -1,3 +1,25 @@
+/**
+ * Copyright (c) 2012, Fedor Indutny.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
#ifndef _SRC_HEAP_H_
#define _SRC_HEAP_H_
@@ -10,14 +32,14 @@
// Both spaces are lists of allocated buffers(pages) with a stack structure
//
-#include "zone.h" // ZoneObject
-#include "gc.h" // GC
-#include "source-map.h" // SourceMap
-#include "utils.h"
+#include <stdint.h> // uint32_t
+#include <unistd.h> // intptr_t
+#include <sys/types.h> // size_t
-#include <stdint.h> // uint32_t
-#include <unistd.h> // intptr_t
-#include <sys/types.h> // size_t
+#include "zone.h" // ZoneObject
+#include "gc.h" // GC
+#include "source-map.h" // SourceMap
+#include "utils.h"
namespace candor {
namespace internal {
@@ -32,7 +54,7 @@ class Space {
public:
class Page {
public:
- Page(uint32_t size) : size_(size) {
+ explicit Page(uint32_t size) : size_(size) {
data_ = new char[size];
// Make all offsets odd (pointers are tagged with 1 at last bit)
top_ = data_ + 1;
@@ -167,9 +189,9 @@ class Heap {
static const uint32_t kICDisabledValue = 0xABBAABBA;
static const uint32_t kICZapValue = 0xABBADEEC;
- Heap(uint32_t page_size);
+ explicit Heap(uint32_t page_size);
- // TODO: Use thread id
+ // TODO(indutny): Use thread id
static inline Heap* Current() { return current_; }
static const char* ErrorToString(Error err);
@@ -624,7 +646,7 @@ class HCData : public HValue {
#undef HINTERIOR_OFFSET
-} // namespace internal
-} // namespace candor
+} // namespace internal
+} // namespace candor
-#endif // _SRC_HEAP_H_
+#endif // _SRC_HEAP_H_
View
50 src/hir-inl.h
@@ -1,13 +1,35 @@
+/**
+ * Copyright (c) 2012, Fedor Indutny.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
#ifndef _SRC_HIR_INL_H_
#define _SRC_HIR_INL_H_
#ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS
-#endif // _STDC_FORMAT_MACROS
-#include <inttypes.h> // PRIu64
+#endif // _STDC_FORMAT_MACROS
+#include <inttypes.h> // PRIu64
+#include <assert.h>
#include "hir.h"
-#include <assert.h>
namespace candor {
namespace internal {
@@ -454,14 +476,14 @@ inline void HIRBlock::Print(PrintBuffer* p) {
}
switch (succ_count_) {
- case 1:
- p->Print("# succ: %d\n--------\n", succ_[0]->id);
- break;
- case 2:
- p->Print("# succ: %d %d\n--------\n", succ_[0]->id, succ_[1]->id);
- break;
- default:
- break;
+ case 1:
+ p->Print("# succ: %d\n--------\n", succ_[0]->id);
+ break;
+ case 2:
+ p->Print("# succ: %d %d\n--------\n", succ_[0]->id, succ_[1]->id);
+ break;
+ default:
+ break;
}
}
@@ -524,7 +546,7 @@ inline HIRBlockList* BreakContinueInfo::continue_blocks() {
return &continue_blocks_;
}
-} // namespace internal
-} // namespace candor
+} // namespace internal
+} // namespace candor
-#endif // _SRC_HIR_INL_H_
+#endif // _SRC_HIR_INL_H_
View
40 src/hir-instructions-inl.h
@@ -1,3 +1,25 @@
+/**
+ * Copyright (c) 2012, Fedor Indutny.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
#ifndef _SRC_HIR_INSTRUCTIONS_INL_H_
#define _SRC_HIR_INSTRUCTIONS_INL_H_
@@ -37,18 +59,18 @@ inline bool HIRInstruction::IsRemoved() {
}
#define HIR_INSTRUCTION_STR(I) \
- case k##I: \
- res = #I; \
- break;
+ case k##I: \
+ res = #I; \
+ break;
inline const char* HIRInstruction::TypeToStr(Type type) {
const char* res;
switch (type) {
HIR_INSTRUCTION_TYPES(HIR_INSTRUCTION_STR)
- default:
- res = "none?!";
- break;
+ default:
+ res = "none?!";
+ break;
}
return res;
@@ -262,7 +284,7 @@ inline int HIRAllocateArray::size() {
return size_;
}
-} // namespace internal
-} // namespace candor
+} // namespace internal
+} // namespace candor
-#endif // _SRC_HIR_INSTRUCTIONS_INL_H_
+#endif // _SRC_HIR_INSTRUCTIONS_INL_H_
View
132 src/hir-instructions.cc
@@ -1,3 +1,25 @@
+/**
+ * Copyright (c) 2012, Fedor Indutny.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
#include "hir.h"
#include "hir-inl.h"
#include "hir-instructions.h"
@@ -6,39 +28,39 @@
namespace candor {
namespace internal {
-HIRInstruction::HIRInstruction(Type type) :
- id(-1),
- gcm_visited(0),
- gvn_visited(0),
- alias_visited(0),
- is_live(0),
- type_(type),
- slot_(NULL),
- ast_(NULL),
- lir_(NULL),
- hashed_(false),
- hash_(0),
- removed_(false),
- pinned_(true),
- representation_(kHoleRepresentation) {
-}
-
-
-HIRInstruction::HIRInstruction(Type type, ScopeSlot* slot) :
- id(-1),
- gcm_visited(0),
- gvn_visited(0),
- alias_visited(0),
- is_live(0),
- type_(type),
- slot_(slot),
- ast_(NULL),
- lir_(NULL),
- hashed_(false),
- hash_(0),
- removed_(false),
- pinned_(true),
- representation_(kHoleRepresentation) {
+HIRInstruction::HIRInstruction(Type type)
+ : id(-1),
+ gcm_visited(0),
+ gvn_visited(0),
+ alias_visited(0),
+ is_live(0),
+ type_(type),
+ slot_(NULL),
+ ast_(NULL),
+ lir_(NULL),
+ hashed_(false),
+ hash_(0),
+ removed_(false),
+ pinned_(true),
+ representation_(kHoleRepresentation) {
+}
+
+
+HIRInstruction::HIRInstruction(Type type, ScopeSlot* slot)
+ : id(-1),
+ gcm_visited(0),
+ gvn_visited(0),
+ alias_visited(0),
+ is_live(0),
+ type_(type),
+ slot_(slot),
+ ast_(NULL),
+ lir_(NULL),
+ hashed_(false),
+ hash_(0),
+ removed_(false),
+ pinned_(true),
+ representation_(kHoleRepresentation) {
}
@@ -270,10 +292,10 @@ bool HIRPhi::Effects(HIRInstruction* instr) {
}
-HIRLiteral::HIRLiteral(AstNode::Type type, ScopeSlot* slot) :
- HIRInstruction(kLiteral),
- type_(type),
- root_slot_(slot) {
+HIRLiteral::HIRLiteral(AstNode::Type type, ScopeSlot* slot)
+ : HIRInstruction(kLiteral),
+ type_(type),
+ root_slot_(slot) {
}
@@ -287,20 +309,20 @@ bool HIRLiteral::IsGVNEqual(HIRInstruction* to) {
void HIRLiteral::CalculateRepresentation() {
switch (type_) {
- case AstNode::kNumber:
- representation_ = root_slot_->is_immediate() ?
+ case AstNode::kNumber:
+ representation_ = root_slot_->is_immediate() ?
kSmiRepresentation : kHeapNumberRepresentation;
- break;
- case AstNode::kString:
- case AstNode::kProperty:
- representation_ = kStringRepresentation;
- break;
- case AstNode::kTrue:
- case AstNode::kFalse:
- representation_ = kBooleanRepresentation;
- break;
- default:
- representation_ = kUnknownRepresentation;
+ break;
+ case AstNode::kString:
+ case AstNode::kProperty:
+ representation_ = kStringRepresentation;
+ break;
+ case AstNode::kTrue:
+ case AstNode::kFalse:
+ representation_ = kBooleanRepresentation;
+ break;
+ default:
+ representation_ = kUnknownRepresentation;
}
}
@@ -441,9 +463,9 @@ bool HIRLoadContext::HasGVNSideEffects() {
}
-HIRStoreContext::HIRStoreContext(ScopeSlot* slot) :
- HIRInstruction(kStoreContext),
- context_slot_(slot) {
+HIRStoreContext::HIRStoreContext(ScopeSlot* slot)
+ : HIRInstruction(kStoreContext),
+ context_slot_(slot) {
}
@@ -649,5 +671,5 @@ void HIRClone::CalculateRepresentation() {
representation_ = kObjectRepresentation;