Remove usages of alloca() according to style guide.
authormstarzinger@chromium.org <mstarzinger@chromium.org>
Wed, 3 Sep 2014 13:23:37 +0000 (13:23 +0000)
committermstarzinger@chromium.org <mstarzinger@chromium.org>
Wed, 3 Sep 2014 13:23:37 +0000 (13:23 +0000)
R=bmeurer@chromium.org

Review URL: https://codereview.chromium.org/535133002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23657 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/compiler/ast-graph-builder.cc
src/compiler/graph-builder.cc
src/compiler/machine-node-factory.h
src/compiler/structured-machine-assembler.cc

index afc58e9..5ad8269 100644 (file)
@@ -1652,7 +1652,7 @@ void AstGraphBuilder::VisitLogicalExpression(BinaryOperation* expr) {
 
 Node* AstGraphBuilder::ProcessArguments(Operator* op, int arity) {
   DCHECK(environment()->stack_height() >= arity);
-  Node** all = info()->zone()->NewArray<Node*>(arity);  // XXX: alloca?
+  Node** all = info()->zone()->NewArray<Node*>(arity);
   for (int i = arity - 1; i >= 0; --i) {
     all[i] = environment()->Pop();
   }
index 504d25e..c41fd6f 100644 (file)
@@ -49,8 +49,7 @@ Node* StructuredGraphBuilder::MakeNode(Operator* op, int value_input_count,
     if (has_framestate) ++input_count_with_deps;
     if (has_control) ++input_count_with_deps;
     if (has_effect) ++input_count_with_deps;
-    void* raw_buffer = alloca(kPointerSize * input_count_with_deps);
-    Node** buffer = reinterpret_cast<Node**>(raw_buffer);
+    Node** buffer = zone()->NewArray<Node*>(input_count_with_deps);
     memcpy(buffer, value_inputs, kPointerSize * value_input_count);
     Node** current_input = buffer + value_input_count;
     if (has_context) {
@@ -163,8 +162,7 @@ void StructuredGraphBuilder::Environment::PrepareForLoop() {
 
 Node* StructuredGraphBuilder::NewPhi(int count, Node* input, Node* control) {
   Operator* phi_op = common()->Phi(count);
-  void* raw_buffer = alloca(kPointerSize * (count + 1));
-  Node** buffer = reinterpret_cast<Node**>(raw_buffer);
+  Node** buffer = zone()->NewArray<Node*>(count + 1);
   MemsetPointer(buffer, input, count);
   buffer[count] = control;
   return graph()->NewNode(phi_op, count + 1, buffer);
@@ -175,8 +173,7 @@ Node* StructuredGraphBuilder::NewPhi(int count, Node* input, Node* control) {
 Node* StructuredGraphBuilder::NewEffectPhi(int count, Node* input,
                                            Node* control) {
   Operator* phi_op = common()->EffectPhi(count);
-  void* raw_buffer = alloca(kPointerSize * (count + 1));
-  Node** buffer = reinterpret_cast<Node**>(raw_buffer);
+  Node** buffer = zone()->NewArray<Node*>(count + 1);
   MemsetPointer(buffer, input, count);
   buffer[count] = control;
   return graph()->NewNode(phi_op, count + 1, buffer);
index 7b2e5ff..a2605d9 100644 (file)
@@ -349,8 +349,7 @@ class MachineNodeFactory {
               MachineType* arg_types, Node** args, int n_args) {
     CallDescriptor* descriptor =
         Linkage::GetSimplifiedCDescriptor(ZONE(), MACHINE_SIG());
-    Node** passed_args =
-        static_cast<Node**>(alloca((n_args + 1) * sizeof(args[0])));
+    Node** passed_args = ZONE()->NewArray<Node*>(n_args + 1);
     passed_args[0] = function_address;
     for (int i = 0; i < n_args; ++i) {
       passed_args[i + 1] = args[i];
index 6475809..432b84c 100644 (file)
@@ -213,8 +213,7 @@ void StructuredMachineAssembler::Merge(EnvironmentVector* environments,
   vars.reserve(n_vars);
   Node** scratch = NULL;
   size_t n_envs = environments->size();
-  Environment** live_environments = reinterpret_cast<Environment**>(
-      alloca(sizeof(environments->at(0)) * n_envs));
+  Environment** live_environments = zone()->NewArray<Environment*>(n_envs);
   size_t n_live = 0;
   for (size_t i = 0; i < n_envs; i++) {
     if (environments->at(i)->is_dead_) continue;
@@ -250,7 +249,7 @@ void StructuredMachineAssembler::Merge(EnvironmentVector* environments,
       CHECK(resolved != NULL);
       // Init scratch buffer.
       if (scratch == NULL) {
-        scratch = static_cast<Node**>(alloca(n_envs * sizeof(resolved)));
+        scratch = zone()->NewArray<Node*>(n_envs);
       }
       for (size_t k = 0; k < i; k++) {
         scratch[k] = resolved;