Commits

Anonymous committed 834d747

alpha.asm: ldgp oublie dans caml_start_program.
array.c: correction de make_array dans le cas d'un tableau d'entiers.

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@163f963ae5c-01c2-4b8c-9fe0-0dff7051ff02

  • Participants
  • Parent commits 7da087e

Comments (0)

Files changed (2)

 caml_c_call:
     /* Function to call is in $27 */
         lda     $sp, -16($sp)
-        stq     $26, 0($sp)
         stq     $gp, 8($sp)
     /* Rebuild $gp */
         br      $25, $105
 $105:   ldgp    $gp, 0($25)
+        stq     $26, 0($sp)
     /* Record lowest stack address and return address */
         stq     $26, caml_last_return_address
 	lda	$25, 16($sp)
         .ent    caml_start_program
         .align  3
 caml_start_program:
+        ldgp    $gp, 0($27)
 	lda	$sp, -128($sp)
         stq     $26, 0($sp)
     /* Save all callee-save registers */
   value res;
   mlsize_t size, wsize, i;
   double d;
-  Push_roots(root, 1);
 
   size = Long_val(len);
   if (size == 0) {
   else if (Is_block(init) && Tag_val(init) == Double_tag) {
     d = Double_val(init);
     wsize = size * Double_wosize;
-    if (wsize > Max_wosize) {
-      Pop_roots();
+    if (wsize > Max_wosize)
       invalid_argument("Array.new");
-    }
     if (wsize < Max_young_wosize)
       res = alloc(wsize, Double_array_tag);
     else
       Store_double_field(res, i, d);
     }
   } else {
+    Push_roots(root, 1);
     if (size > Max_wosize) {
       Pop_roots();
       invalid_argument("Array.new");
       init = root[0];
       for (i = 0; i < size; i++) initialize(&Field(res, i), init);
     }
+    Pop_roots();
   }
-  Pop_roots();
   return res;
 }
 
      value init;
 {
   mlsize_t wsize, size, i;
-  value res;
+  value v, res;
 
   size = Wosize_val(init);
-  if (size == 0 || Tag_val(Field(init, 0)) != Double_tag) {
+  if (size == 0) {
     return init;
   } else {
-    Push_roots(root, 1);
-    root[0] = init;
-    wsize = size * Double_wosize;
-    if (wsize > Max_wosize) {
-      Pop_roots();
-      invalid_argument("Array.new");
-    }
-    if (wsize < Max_young_wosize)
-      res = alloc(wsize, Double_array_tag);
-    else
-      res = alloc_shr(wsize, Double_array_tag);
-    init = root[0];
-    for (i = 0; i < size; i++) {
-      Store_double_field(res, i, Double_val(Field(init, i)));
+    v = Field(init, 0);
+    if (Is_long(v) || Tag_val(v) != Double_tag) {
+      return init;
+    } else {
+      Push_roots(root, 1);
+      root[0] = init;
+      wsize = size * Double_wosize;
+      if (wsize > Max_wosize) {
+        Pop_roots();
+        invalid_argument("Array.new");
+      }
+      if (wsize < Max_young_wosize)
+        res = alloc(wsize, Double_array_tag);
+      else
+        res = alloc_shr(wsize, Double_array_tag);
+      init = root[0];
+      for (i = 0; i < size; i++) {
+        Store_double_field(res, i, Double_val(Field(init, i)));
+      }
+      return res;
     }
-    return res;
   }
 }