Revision: 22749
Author:   [email protected]
Date:     Thu Jul 31 11:31:39 2014 UTC
Log:      More memory leak fixes.

[email protected]

Review URL: https://codereview.chromium.org/437523002
http://code.google.com/p/v8/source/detail?r=22749

Modified:
 /branches/bleeding_edge/test/cctest/compiler/test-instruction.cc
 /branches/bleeding_edge/test/cctest/compiler/test-js-typed-lowering.cc

=======================================
--- /branches/bleeding_edge/test/cctest/compiler/test-instruction.cc Wed Jul 30 16:21:36 2014 UTC +++ /branches/bleeding_edge/test/cctest/compiler/test-instruction.cc Thu Jul 31 11:31:39 2014 UTC
@@ -34,6 +34,8 @@
         common(zone()),
         machine(zone(), kMachineWord32),
         code(NULL) {}
+
+  ~InstructionTester() { delete code; }

   Isolate* isolate;
   Graph graph;
=======================================
--- /branches/bleeding_edge/test/cctest/compiler/test-js-typed-lowering.cc Wed Jul 30 13:54:45 2014 UTC +++ /branches/bleeding_edge/test/cctest/compiler/test-js-typed-lowering.cc Thu Jul 31 11:31:39 2014 UTC
@@ -260,22 +260,23 @@
 class JSBitwiseShiftTypedLoweringTester : public JSTypedLoweringTester {
  public:
   static const int kNumberOps = 6;
-  Operator** ops;
-  bool* signedness;
+  Operator* ops[kNumberOps];
+  bool signedness[kNumberOps];

   JSBitwiseShiftTypedLoweringTester() {
-    Operator* o[] = {javascript.ShiftLeft(),         machine.Word32Shl(),
-                     javascript.ShiftRight(),        machine.Word32Sar(),
-                     javascript.ShiftRightLogical(), machine.Word32Shr()};
+    int i = 0;
+    set(i++, javascript.ShiftLeft(), true);
+    set(i++, machine.Word32Shl(), false);
+    set(i++, javascript.ShiftRight(), true);
+    set(i++, machine.Word32Sar(), false);
+    set(i++, javascript.ShiftRightLogical(), false);
+    set(i++, machine.Word32Shr(), false);
+  }

-    ops = static_cast<Operator**>(malloc(sizeof(o)));
-    memcpy(ops, o, sizeof(o));
-
-    // Expected signedness of left and right conversions above.
-    bool s[] = {true, false, true, false, false, false};
-
-    signedness = static_cast<bool*>(malloc(sizeof(s)));
-    memcpy(signedness, s, sizeof(s));
+ private:
+  void set(int idx, Operator* op, bool s) {
+    ops[idx] = op;
+    signedness[idx] = s;
   }
 };

@@ -319,22 +320,23 @@
 class JSBitwiseTypedLoweringTester : public JSTypedLoweringTester {
  public:
   static const int kNumberOps = 6;
-  Operator** ops;
-  bool* signedness;
+  Operator* ops[kNumberOps];
+  bool signedness[kNumberOps];

   JSBitwiseTypedLoweringTester() {
-    Operator* o[] = {javascript.BitwiseOr(),  machine.Word32Or(),
-                     javascript.BitwiseXor(), machine.Word32Xor(),
-                     javascript.BitwiseAnd(), machine.Word32And()};
-
-    ops = static_cast<Operator**>(malloc(sizeof(o)));
-    memcpy(ops, o, sizeof(o));
-
-    // Expected signedness of left and right conversions above.
-    bool s[] = {true, true, true, true, true, true};
+    int i = 0;
+    set(i++, javascript.BitwiseOr(), true);
+    set(i++, machine.Word32Or(), true);
+    set(i++, javascript.BitwiseXor(), true);
+    set(i++, machine.Word32Xor(), true);
+    set(i++, javascript.BitwiseAnd(), true);
+    set(i++, machine.Word32And(), true);
+  }

-    signedness = static_cast<bool*>(malloc(sizeof(s)));
-    memcpy(signedness, s, sizeof(s));
+ private:
+  void set(int idx, Operator* op, bool s) {
+    ops[idx] = op;
+    signedness[idx] = s;
   }
 };

--
--
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.

Reply via email to