Package com.facebook.presto.jdbc.internal.jol.info

Examples of com.facebook.presto.jdbc.internal.jol.info.FieldLayout


                int scale = VMSupport.U.arrayIndexScale(Class.forName(data.arrayClass()));

                int instanceSize = VMSupport.align(base + (data.arrayLength()) * scale, 8);

                SortedSet<FieldLayout> result = new TreeSet<FieldLayout>();
                result.add(new FieldLayout(FieldData.create(data.arrayClass(), "length", "int"), model.headerSize(), model.sizeOf("int")));
                result.add(new FieldLayout(FieldData.create(data.arrayClass(), "<elements>", data.arrayComponentType()), base, scale * data.arrayLength()));
                return new ClassLayout(data, result, model.headerSize(), instanceSize, false);
            } catch (ClassNotFoundException e) {
                throw new IllegalStateException("Should not reach here.", e);
            }
        }

        Collection<FieldData> fields = data.fields();

        SortedSet<FieldLayout> result = new TreeSet<FieldLayout>();
        for (FieldData f : fields) {
            result.add(new FieldLayout(f, f.vmOffset(), model.sizeOf(f.typeClass())));
        }

        int instanceSize;
        if (result.isEmpty()) {
            instanceSize = VMSupport.align(model.headerSize());
        } else {
            FieldLayout f = result.last();
            instanceSize = VMSupport.align(f.offset() + f.size());
        }
        return new ClassLayout(data, result, model.headerSize(), instanceSize, true);
    }
View Full Code Here


            int instanceSize = base + cd.arrayLength() * scale;

            instanceSize = VMSupport.align(instanceSize, autoAlign ? Math.max(4, scale) : 8);
            base = VMSupport.align(base, Math.max(4, scale));

            result.add(new FieldLayout(FieldData.create(cd.arrayClass(), "length", "int"), model.headerSize(), model.sizeOf("int")));
            result.add(new FieldLayout(FieldData.create(cd.arrayClass(), "<elements>", cd.arrayComponentType()), base, scale * cd.arrayLength()));
            return new ClassLayout(cd, result, model.headerSize(), instanceSize, false);
        }

        List<String> hierarchy = cd.classHierarchy();

        BitSet claimed = new BitSet();

        claimed.set(0, model.headerSize());

        for (String k : hierarchy) {

            Collection<FieldData> fields = cd.fieldsFor(k);

            SortedSet<FieldLayout> current = new TreeSet<FieldLayout>();
            for (int size : new int[]{8, 4, 2, 1}) {
                for (FieldData f : fields) {
                    int fSize = model.sizeOf(f.typeClass());
                    if (fSize != size) continue;

                    for (int t = 0; t < Integer.MAX_VALUE; t++) {
                        if (claimed.get(t * size, (t + 1) * size).isEmpty()) {
                            claimed.set(t * size, (t + 1) * size);
                            current.add(new FieldLayout(f, t * size, size));
                            break;
                        }
                    }
                }
            }
View Full Code Here

            // special case of arrays
            int base = model.headerSize() + model.sizeOf("int");
            int scale = model.sizeOf(data.arrayComponentType());

            int instanceSize = base + (data.arrayLength()) * scale;
            result.add(new FieldLayout(FieldData.create(data.arrayClass(), "length", "int"), model.headerSize(), model.sizeOf("int")));
            result.add(new FieldLayout(FieldData.create(data.arrayClass(), "<elements>", data.arrayComponentType()), base, scale * data.arrayLength()));
            return new ClassLayout(data, result, model.headerSize(), instanceSize, false);
        }

        int offset = model.headerSize();
        for (FieldData f : data.fields()) {
            int size = model.sizeOf(f.typeClass());
            result.add(new FieldLayout(f, offset, size));
            offset += size;
        }

        if (result.isEmpty()) {
            return new ClassLayout(data, result, model.headerSize(), model.headerSize(), false);
        } else {
            FieldLayout f = result.last();
            return new ClassLayout(data, result, model.headerSize(), f.offset() + f.size(), false);
        }
    }
View Full Code Here

TOP

Related Classes of com.facebook.presto.jdbc.internal.jol.info.FieldLayout

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.