Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005769OCamlOCaml backend (code generation)public2012-10-01 18:312013-12-17 19:49
Reporterchambart 
Assigned Tochambart 
PrioritynormalSeverityfeatureReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version4.00.0 
Target VersionFixed in Version4.01.0 
Summary0005769: [patch] allow propagation of Sys.big_endian in native code
DescriptionWhen writing machine specific code like

let read_int32_little_endian v n =
  let v = raw_read_int32 v n in
  if Sys.big_endian
  then swap_bytes v
  else v

It would be prettier to know that the compiler cleans the test rather than having to use a preprocessor for that.

The patch provided add a primitive %big_endian of type unit -> bool that calls a C stub in byte code and is simplified in native code
Tagspatch
Attached Filespatch file icon 0002-Add-primitives-for-compile-time-constants.patch [^] (6,493 bytes) 2012-11-09 16:03 [Show Content]
patch file icon 0004-Add-primitives-for-compile-time-constants-library-pa.patch [^] (1,974 bytes) 2012-11-09 16:03 [Show Content]

- Relationships

-  Notes
(0008185)
chambart (developer)
2012-10-01 18:37

The first patch had spurious trailing white space removal cleaned in the second patch
(0008189)
chambart (developer)
2012-10-02 11:38

Added a patch allowing propagation of other compile time constants.

It makes things like

let int_of_uint16 i =
  let n = Sys.word_size - 17 in
  (i lsl n) asr n

more efficient.

What other constant could be added ?
(0008190)
johnwhitington (reporter)
2012-10-02 13:05
edited on: 2012-10-02 13:12

Presumably Nativeint.size:

let sign_extend l n =
  let shift = Nativeint.size - 1 - l in
    (n lsl shift) asr shift

Although I suppose the gain is smaller here because l is non-constant.

(0008223)
chambart (developer)
2012-10-08 13:59

It is not needed to change Nativeint.size because it is computed using Sys.bigendian.
(0008477)
chambart (developer)
2012-11-09 16:04

Add version updated for current trunk.
Separate patch in 2 parts: to apply before and after bootstraping
(0010741)
chambart (developer)
2013-12-17 19:48

Commited to 4.01

- Issue History
Date Modified Username Field Change
2012-10-01 18:31 chambart New Issue
2012-10-01 18:31 chambart File Added: bigendian.patch
2012-10-01 18:36 chambart File Added: bigendian.patch2
2012-10-01 18:37 chambart Note Added: 0008185
2012-10-02 11:35 chambart File Added: compile_time_constant.patch
2012-10-02 11:38 chambart Note Added: 0008189
2012-10-02 13:05 johnwhitington Note Added: 0008190
2012-10-02 13:12 johnwhitington Note Edited: 0008190 View Revisions
2012-10-08 13:59 chambart Note Added: 0008223
2012-11-09 16:03 chambart File Added: 0002-Add-primitives-for-compile-time-constants.patch
2012-11-09 16:03 chambart File Added: 0004-Add-primitives-for-compile-time-constants-library-pa.patch
2012-11-09 16:04 chambart Note Added: 0008477
2012-11-09 16:56 lefessan File Deleted: bigendian.patch
2012-11-09 16:56 lefessan File Deleted: bigendian.patch2
2012-11-09 16:56 lefessan File Deleted: compile_time_constant.patch
2012-11-15 19:44 doligez Status new => acknowledged
2013-12-16 13:13 doligez Tag Attached: patch
2013-12-17 19:48 chambart Note Added: 0010741
2013-12-17 19:49 chambart Status acknowledged => resolved
2013-12-17 19:49 chambart Fixed in Version => 4.01.0
2013-12-17 19:49 chambart Resolution open => fixed
2013-12-17 19:49 chambart Assigned To => chambart


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker