ObjectClassGenerator.java (953:221a84ef44c0) ObjectClassGenerator.java (1006:f04f14587586)
1/*
2 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided

--- 39 unchanged lines hidden (view full) ---

48
49import java.lang.invoke.MethodHandle;
50import java.lang.invoke.MethodHandles;
51import java.lang.invoke.MethodType;
52import java.util.EnumSet;
53import java.util.Iterator;
54import java.util.LinkedList;
55import java.util.List;
1/*
2 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided

--- 39 unchanged lines hidden (view full) ---

48
49import java.lang.invoke.MethodHandle;
50import java.lang.invoke.MethodHandles;
51import java.lang.invoke.MethodType;
52import java.util.EnumSet;
53import java.util.Iterator;
54import java.util.LinkedList;
55import java.util.List;
56
56import jdk.nashorn.internal.codegen.ClassEmitter.Flag;
57import jdk.nashorn.internal.codegen.types.Type;
58import jdk.nashorn.internal.runtime.AccessorProperty;
59import jdk.nashorn.internal.runtime.Context;
60import jdk.nashorn.internal.runtime.FunctionScope;
61import jdk.nashorn.internal.runtime.JSType;
62import jdk.nashorn.internal.runtime.PropertyMap;
63import jdk.nashorn.internal.runtime.ScriptEnvironment;

--- 239 unchanged lines hidden (view full) ---

303
304 final MethodEmitter initWithSpillArrays = newInitWithSpillArraysMethod(classEmitter, ScriptObject.class);
305 initWithSpillArrays.returnVoid();
306 initWithSpillArrays.end();
307
308 newEmptyInit(className, classEmitter);
309 newAllocate(className, classEmitter);
310
57import jdk.nashorn.internal.codegen.ClassEmitter.Flag;
58import jdk.nashorn.internal.codegen.types.Type;
59import jdk.nashorn.internal.runtime.AccessorProperty;
60import jdk.nashorn.internal.runtime.Context;
61import jdk.nashorn.internal.runtime.FunctionScope;
62import jdk.nashorn.internal.runtime.JSType;
63import jdk.nashorn.internal.runtime.PropertyMap;
64import jdk.nashorn.internal.runtime.ScriptEnvironment;

--- 239 unchanged lines hidden (view full) ---

304
305 final MethodEmitter initWithSpillArrays = newInitWithSpillArraysMethod(classEmitter, ScriptObject.class);
306 initWithSpillArrays.returnVoid();
307 initWithSpillArrays.end();
308
309 newEmptyInit(className, classEmitter);
310 newAllocate(className, classEmitter);
311
311 return toByteArray(classEmitter);
312 return toByteArray(className, classEmitter);
312 }
313
314 /**
315 * Generate the byte codes for a JavaScript scope class with fieldCount fields
316 * and paramCount parameters.
317 *
318 * @param fieldCount Number of fields in the JavaScript scope.
319 * @param paramCount Number of parameters in the JavaScript scope

--- 16 unchanged lines hidden (view full) ---

336 initWithSpillArrays.returnVoid();
337 initWithSpillArrays.end();
338
339 final MethodEmitter initWithArguments = newInitScopeWithArgumentsMethod(classEmitter);
340 initializeToUndefined(initWithArguments, className, initFields);
341 initWithArguments.returnVoid();
342 initWithArguments.end();
343
313 }
314
315 /**
316 * Generate the byte codes for a JavaScript scope class with fieldCount fields
317 * and paramCount parameters.
318 *
319 * @param fieldCount Number of fields in the JavaScript scope.
320 * @param paramCount Number of parameters in the JavaScript scope

--- 16 unchanged lines hidden (view full) ---

337 initWithSpillArrays.returnVoid();
338 initWithSpillArrays.end();
339
340 final MethodEmitter initWithArguments = newInitScopeWithArgumentsMethod(classEmitter);
341 initializeToUndefined(initWithArguments, className, initFields);
342 initWithArguments.returnVoid();
343 initWithArguments.end();
344
344 return toByteArray(classEmitter);
345 return toByteArray(className, classEmitter);
345 }
346
347 /**
348 * Generates the needed fields.
349 *
350 * @param classEmitter Open class emitter.
351 * @param fieldCount Number of fields.
352 *

--- 126 unchanged lines hidden (view full) ---

479 }
480
481 /**
482 * Collects the byte codes for a generated JavaScript class.
483 *
484 * @param classEmitter Open class emitter.
485 * @return Byte codes for the class.
486 */
346 }
347
348 /**
349 * Generates the needed fields.
350 *
351 * @param classEmitter Open class emitter.
352 * @param fieldCount Number of fields.
353 *

--- 126 unchanged lines hidden (view full) ---

480 }
481
482 /**
483 * Collects the byte codes for a generated JavaScript class.
484 *
485 * @param classEmitter Open class emitter.
486 * @return Byte codes for the class.
487 */
487 private byte[] toByteArray(final ClassEmitter classEmitter) {
488 private byte[] toByteArray(final String className, final ClassEmitter classEmitter) {
488 classEmitter.end();
489
490 final byte[] code = classEmitter.toByteArray();
491 final ScriptEnvironment env = context.getEnv();
492
489 classEmitter.end();
490
491 final byte[] code = classEmitter.toByteArray();
492 final ScriptEnvironment env = context.getEnv();
493
493 if (env._print_code && env._print_code_dir == null) {
494 env.getErr().println(ClassEmitter.disassemble(code));
495 }
494 DumpBytecode.dumpBytecode(env, log, code, className);
496
497 if (env._verify_code) {
498 context.verify(code);
499 }
500
501 return code;
502 }
503

--- 328 unchanged lines hidden ---
495
496 if (env._verify_code) {
497 context.verify(code);
498 }
499
500 return code;
501 }
502

--- 328 unchanged lines hidden ---