njvminl.pas 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673
  1. {
  2. Copyright (c) 1998-2011 by Florian Klaempfl and Jonas Maebe
  3. Generate JVM inline nodes
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************
  16. }
  17. unit njvminl;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. cpubase,
  22. node,ninl,ncginl;
  23. type
  24. tjvminlinenode = class(tcginlinenode)
  25. protected
  26. function typecheck_length(var handled: boolean): tnode;
  27. function typecheck_high(var handled: boolean): tnode;
  28. function typecheck_new(var handled: boolean): tnode;
  29. function first_setlength_array: tnode;
  30. function first_setlength_string: tnode;
  31. public
  32. { typecheck override to intercept handling }
  33. function pass_typecheck: tnode; override;
  34. { first pass override
  35. so that the code generator will actually generate
  36. these nodes.
  37. }
  38. (*
  39. function first_sqrt_real: tnode; override;
  40. *)
  41. function first_sqr_real: tnode; override;
  42. function first_trunc_real: tnode; override;
  43. (*
  44. function first_round_real: tnode; override;
  45. *)
  46. function first_new: tnode; override;
  47. function first_setlength: tnode; override;
  48. function first_length: tnode; override;
  49. procedure second_length; override;
  50. (*
  51. procedure second_sqrt_real; override;
  52. procedure second_abs_real; override;
  53. *)
  54. procedure second_sqr_real; override;
  55. procedure second_trunc_real; override;
  56. (*
  57. procedure second_round_real; override;
  58. *)
  59. procedure second_new; override;
  60. procedure second_setlength; override;
  61. protected
  62. procedure load_fpu_location;
  63. end;
  64. implementation
  65. uses
  66. cutils,globals,verbose,globtype,constexp,
  67. aasmbase,aasmtai,aasmdata,aasmcpu,
  68. symtype,symconst,symdef,symsym,symtable,jvmdef,
  69. defutil,
  70. nbas,ncon,ncnv,ncal,nld,nflw,nutils,
  71. cgbase,pass_1,pass_2,
  72. cpuinfo,ncgutil,
  73. cgutils,hlcgobj,hlcgcpu;
  74. {*****************************************************************************
  75. tjvminlinenode
  76. *****************************************************************************}
  77. function tjvminlinenode.typecheck_length(var handled: boolean): tnode;
  78. begin
  79. typecheckpass(left);
  80. if is_dynamic_array(left.resultdef) or
  81. is_open_array(left.resultdef) or
  82. is_wide_or_unicode_string(left.resultdef) then
  83. begin
  84. resultdef:=s32inttype;
  85. result:=nil;
  86. handled:=true;
  87. end;
  88. end;
  89. function tjvminlinenode.typecheck_high(var handled: boolean): tnode;
  90. begin
  91. typecheckpass(left);
  92. if is_dynamic_array(left.resultdef) or
  93. is_open_array(left.resultdef) then
  94. begin
  95. { replace with pred(length(arr)) }
  96. result:=cinlinenode.create(in_pred_x,false,
  97. cinlinenode.create(in_length_x,false,left));
  98. left:=nil;
  99. handled:=true;
  100. end;
  101. end;
  102. function tjvminlinenode.typecheck_new(var handled: boolean): tnode;
  103. var
  104. para: tcallparanode;
  105. elemdef: tdef;
  106. begin
  107. { normally never exists; used by the JVM backend to create new
  108. arrays because it requires special opcodes }
  109. tcallparanode(left).get_paratype;
  110. if is_dynamic_array(left.resultdef) then
  111. begin
  112. para:=tcallparanode(left);
  113. { need at least one extra parameter in addition to the
  114. array }
  115. if not assigned(para.right) then
  116. internalerror(2011012206);
  117. elemdef:=tarraydef(left.resultdef).elementdef;
  118. while elemdef.typ=arraydef do
  119. begin
  120. { if we have less length specifiers than dimensions, make
  121. the last array an array of length 0 }
  122. if not assigned(para.right) then
  123. begin
  124. para.right:=ccallparanode.create(
  125. cordconstnode.create(0,s32inttype,false),nil);
  126. tcallparanode(para.right).get_paratype;
  127. break;
  128. end
  129. else
  130. begin
  131. inserttypeconv(tcallparanode(para.right).left,s32inttype);
  132. tcallparanode(para.right).get_paratype;
  133. end;
  134. para:=tcallparanode(para.right);
  135. elemdef:=tarraydef(elemdef).elementdef;
  136. end;
  137. result:=nil;
  138. resultdef:=left.resultdef;
  139. handled:=true;
  140. end;
  141. end;
  142. function tjvminlinenode.pass_typecheck: tnode;
  143. var
  144. handled: boolean;
  145. begin
  146. handled:=false;
  147. case inlinenumber of
  148. in_length_x:
  149. begin
  150. result:=typecheck_length(handled);
  151. end;
  152. in_high_x:
  153. begin
  154. result:=typecheck_high(handled);
  155. end;
  156. in_new_x:
  157. begin
  158. result:=typecheck_new(handled);
  159. end;
  160. end;
  161. if not handled then
  162. result:=inherited pass_typecheck;
  163. end;
  164. (*
  165. function tjvminlinenode.first_sqrt_real : tnode;
  166. begin
  167. if (current_settings.cputype >= cpu_PPC970) then
  168. begin
  169. expectloc:=LOC_FPUREGISTER;
  170. first_sqrt_real := nil;
  171. end
  172. else
  173. result:=inherited first_sqrt_real;
  174. end;
  175. *)
  176. function tjvminlinenode.first_sqr_real : tnode;
  177. begin
  178. expectloc:=LOC_FPUREGISTER;
  179. first_sqr_real:=nil;
  180. end;
  181. function tjvminlinenode.first_trunc_real : tnode;
  182. begin
  183. expectloc:=LOC_REGISTER;
  184. first_trunc_real:=nil;
  185. end;
  186. function tjvminlinenode.first_new: tnode;
  187. begin
  188. { skip the array; it's a type node }
  189. tcallparanode(tcallparanode(left).right).firstcallparan;
  190. expectloc:=LOC_REGISTER;
  191. result:=nil;
  192. end;
  193. function tjvminlinenode.first_setlength_array: tnode;
  194. var
  195. assignmenttarget,
  196. ppn,
  197. newparas: tnode;
  198. newnode: tnode;
  199. eledef,
  200. objarraydef: tdef;
  201. ndims: longint;
  202. finaltype: char;
  203. setlenroutine: string;
  204. lefttemp: ttempcreatenode;
  205. newblock: tblocknode;
  206. newstatement: tstatementnode;
  207. primitive: boolean;
  208. begin
  209. { first parameter is the array, the rest are the dimensions }
  210. newparas:=tcallparanode(left).right;
  211. tcallparanode(left).right:=nil;
  212. { count the number of specified dimensions, and determine the type of
  213. the final one }
  214. ppn:=newparas;
  215. eledef:=tarraydef(left.resultdef).elementdef;
  216. { ppn already points to the first dimension }
  217. ndims:=1;
  218. while assigned(tcallparanode(ppn).right) do
  219. begin
  220. inc(ndims);
  221. eledef:=tarraydef(eledef).elementdef;
  222. ppn:=tcallparanode(ppn).right;
  223. end;
  224. { in case it's a dynamic array of static arrays, we must also allocate
  225. the static arrays! }
  226. while (eledef.typ=arraydef) and
  227. not is_dynamic_array(eledef) do
  228. begin
  229. inc(ndims);
  230. tcallparanode(ppn).right:=
  231. ccallparanode.create(
  232. genintconstnode(tarraydef(eledef).elecount),nil);
  233. ppn:=tcallparanode(ppn).right;
  234. eledef:=tarraydef(eledef).elementdef;
  235. end;
  236. { prepend type parameter for the array }
  237. newparas:=ccallparanode.create(ctypenode.create(left.resultdef),newparas);
  238. ttypenode(tcallparanode(newparas).left).allowed:=true;
  239. { node to create the new array }
  240. newnode:=cinlinenode.create(in_new_x,false,newparas);
  241. { Common parameters for setlength helper }
  242. { start with org (save assignmenttarget itself to assign the result back to) }
  243. { store left into a temp in case it may contain a function call
  244. (which must not be evaluated twice) }
  245. lefttemp:=maybereplacewithtempref(tcallparanode(left).left,tcallparanode(left).left.resultdef.size,false);
  246. if assigned(lefttemp) then
  247. begin
  248. newblock:=internalstatements(newstatement);
  249. addstatement(newstatement,lefttemp);
  250. assignmenttarget:=ctemprefnode.create(lefttemp);
  251. typecheckpass(tnode(assignmenttarget));
  252. end
  253. else
  254. assignmenttarget:=tcallparanode(left).left.getcopy;
  255. newparas:=left;
  256. left:=nil;
  257. { if more than 1 dimension, or if 1 dimention of a non-primitive type,
  258. typecast to generic array of tobject }
  259. setlenroutine:=jvmarrtype(eledef,primitive);
  260. finaltype:=jvmarrtype_setlength(eledef);
  261. { since the setlength prototypes require certain types, insert
  262. explicit type conversions where necessary }
  263. objarraydef:=nil;
  264. { all arrays, records and object types need to be handled as JLObject }
  265. if (ndims>1) or
  266. not primitive then
  267. objarraydef:=search_system_type('TJOBJECTARRAY').typedef
  268. { insert type conversion, because this is used both for signed and
  269. unsigned types }
  270. else case finaltype of
  271. 'Z': { boolean is always the same };
  272. 'C': { char is always the same };
  273. 'B':
  274. { jbyte: used for both shortint and byte }
  275. objarraydef:=search_system_type('TJBYTEARRAY').typedef;
  276. 'S':
  277. { jshort: used for both smallint and word }
  278. objarraydef:=search_system_type('TJSHORTARRAY').typedef;
  279. 'I':
  280. { jshort: used for both smallint and word }
  281. objarraydef:=search_system_type('TJINTARRAY').typedef;
  282. 'J':
  283. { jshort: used for both smallint and word }
  284. objarraydef:=search_system_type('TJLONGARRAY').typedef;
  285. 'F': { float is always the same };
  286. 'D': { double is always the same };
  287. else
  288. internalerror(2011040705);
  289. end;
  290. if assigned(objarraydef) then
  291. begin
  292. tcallparanode(newparas).left:=ctypeconvnode.create_explicit(tcallparanode(newparas).left,objarraydef);
  293. newnode:=ctypeconvnode.create_explicit(newnode,objarraydef);
  294. end;
  295. { prepend new }
  296. newparas:=ccallparanode.create(newnode,newparas);
  297. { prepend deepcopy }
  298. newparas:=ccallparanode.create(cordconstnode.create(0,pasbool8type,false),newparas);
  299. { call the right setlenght helper }
  300. if ndims>1 then
  301. begin
  302. setlenroutine:='FPC_SETLENGTH_DYNARR_MULTIDIM';
  303. { create proper parameters, from right to left:
  304. eletype=finaltype, ndim=ndims, deepcopy=false, new=newnode,
  305. assignmenttarget=tcallparanode(left).left }
  306. { prepend ndim }
  307. newparas:=ccallparanode.create(cordconstnode.create(ndims,s32inttype,false),newparas);
  308. { prepend eletype }
  309. newparas:=ccallparanode.create(cordconstnode.create(ord(finaltype),cwidechartype,false),newparas);
  310. end
  311. else
  312. begin
  313. if not primitive then
  314. setlenroutine:='OBJECT'
  315. else
  316. uppervar(setlenroutine);
  317. setlenroutine:='FPC_SETLENGTH_DYNARR_J'+setlenroutine;
  318. { create proper parameters, from right to left:
  319. deepcopy=false, new=newnode, assignmenttarget=tcallparnode(left).left
  320. -> already done in common part above }
  321. end;
  322. result:=ccallnode.createintern(setlenroutine,newparas);
  323. { assign result back to org (no call-by-reference for Java) }
  324. result:=cassignmentnode.create(assignmenttarget,
  325. ctypeconvnode.create_explicit(result,assignmenttarget.resultdef));
  326. if assigned(lefttemp) then
  327. begin
  328. addstatement(newstatement,result);
  329. addstatement(newstatement,ctempdeletenode.create(lefttemp));
  330. result:=newblock;
  331. end;
  332. end;
  333. function tjvminlinenode.first_setlength_string: tnode;
  334. var
  335. newblock: tblocknode;
  336. newstatement: tstatementnode;
  337. lefttemp: ttempcreatenode;
  338. assignmenttarget: tnode;
  339. begin
  340. if is_wide_or_unicode_string(left.resultdef) then
  341. begin
  342. { store left into a temp in case it may contain a function call
  343. (which must not be evaluated twice) }
  344. lefttemp:=maybereplacewithtempref(tcallparanode(left).left,tcallparanode(left).left.resultdef.size,false);
  345. if assigned(lefttemp) then
  346. begin
  347. newblock:=internalstatements(newstatement);
  348. addstatement(newstatement,lefttemp);
  349. assignmenttarget:=ctemprefnode.create(lefttemp);
  350. typecheckpass(tnode(assignmenttarget));
  351. end
  352. else
  353. assignmenttarget:=tcallparanode(left).left.getcopy;
  354. { back to original order for the call }
  355. left:=reverseparameters(tcallparanode(left));
  356. result:=cassignmentnode.create(assignmenttarget,
  357. ccallnode.createintern('fpc_unicodestr_setlength',left));
  358. if assigned(lefttemp) then
  359. begin
  360. addstatement(newstatement,result);
  361. addstatement(newstatement,ctempdeletenode.create(lefttemp));
  362. result:=newblock;
  363. end;
  364. left:=nil;
  365. end
  366. {$ifndef nounsupported}
  367. else if left.resultdef.typ=stringdef then
  368. begin
  369. result:=cnothingnode.create;
  370. end
  371. {$endif}
  372. else
  373. internalerror(2011031405);
  374. end;
  375. function tjvminlinenode.first_setlength: tnode;
  376. begin
  377. { reverse the parameter order so we can process them more easily }
  378. left:=reverseparameters(tcallparanode(left));
  379. { treat setlength(x,0) specially: used to init uninitialised locations }
  380. if not assigned(tcallparanode(tcallparanode(left).right).right) and
  381. is_constintnode(tcallparanode(tcallparanode(left).right).left) and
  382. (tordconstnode(tcallparanode(tcallparanode(left).right).left).value=0) then
  383. begin
  384. result:=nil;
  385. expectloc:=LOC_VOID;
  386. exit;
  387. end;
  388. case left.resultdef.typ of
  389. arraydef:
  390. result:=first_setlength_array;
  391. stringdef:
  392. result:=first_setlength_string;
  393. else
  394. internalerror(2011031204);
  395. end;
  396. end;
  397. function tjvminlinenode.first_length: tnode;
  398. var
  399. newblock: tblocknode;
  400. newstatement: tstatementnode;
  401. lentemp: ttempcreatenode;
  402. ifcond,
  403. stringnonnull,
  404. stringnull: tnode;
  405. psym: tsym;
  406. begin
  407. if is_wide_or_unicode_string(left.resultdef) then
  408. begin
  409. { if assigned(JLString(left)) then
  410. lentemp:=JLString(left).length()
  411. else
  412. lentemp:=0;
  413. --> return lentemp
  414. }
  415. newblock:=internalstatements(newstatement);
  416. lentemp:=ctempcreatenode.create(s32inttype,s32inttype.size,tt_persistent,true);
  417. addstatement(newstatement,lentemp);
  418. { if-condition }
  419. ifcond:=cinlinenode.create(in_assigned_x,false,
  420. ccallparanode.create(ctypeconvnode.create_explicit(left.getcopy,java_jlstring),nil));
  421. { then-path (reuse left, since last use) }
  422. psym:=search_struct_member(java_jlstring,'LENGTH');
  423. if not assigned(psym) or
  424. (psym.typ<>procsym) then
  425. internalerror(2011031403);
  426. stringnonnull:=cassignmentnode.create(
  427. ctemprefnode.create(lentemp),
  428. ccallnode.create(nil,tprocsym(psym),psym.owner,
  429. ctypeconvnode.create_explicit(left,java_jlstring),[]));
  430. left:=nil;
  431. { else-path}
  432. stringnull:=cassignmentnode.create(
  433. ctemprefnode.create(lentemp),
  434. genintconstnode(0));
  435. { complete if-statement }
  436. addstatement(newstatement,cifnode.create(ifcond,stringnonnull,stringnull));
  437. { return temp }
  438. addstatement(newstatement,ctempdeletenode.create_normal_temp(lentemp));
  439. addstatement(newstatement,ctemprefnode.create(lentemp));
  440. result:=newblock;
  441. end
  442. {$ifndef nounsupported}
  443. else if left.resultdef.typ=stringdef then
  444. begin
  445. end
  446. {$endif}
  447. else
  448. result:=inherited first_length;
  449. end;
  450. procedure tjvminlinenode.second_length;
  451. begin
  452. if is_dynamic_array(left.resultdef) or
  453. is_open_array(left.resultdef) then
  454. begin
  455. location_reset(location,LOC_REGISTER,OS_S32);
  456. location.register:=hlcg.getintregister(current_asmdata.CurrAsmList,s32inttype);
  457. secondpass(left);
  458. thlcgjvm(hlcg).g_getarraylen(current_asmdata.CurrAsmList,left.location);
  459. thlcgjvm(hlcg).a_load_stack_reg(current_asmdata.CurrAsmList,resultdef,location.register);
  460. end
  461. {$ifndef nounsupported}
  462. else if left.resultdef.typ=stringdef then
  463. begin
  464. thlcgjvm(hlcg).a_load_const_stack(current_asmdata.CurrAsmList,java_jlobject,0,R_ADDRESSREGISTER);
  465. end
  466. {$endif}
  467. else
  468. internalerror(2011012004);
  469. end;
  470. (*
  471. function tjvminlinenode.first_round_real : tnode;
  472. begin
  473. if (current_settings.cputype >= cpu_PPC970) then
  474. begin
  475. expectloc:=LOC_REFERENCE;
  476. first_round_real := nil;
  477. end
  478. else
  479. result:=inherited first_round_real;
  480. end;
  481. *)
  482. { load the FPU value on the evaluation stack }
  483. procedure tjvminlinenode.load_fpu_location;
  484. begin
  485. secondpass(left);
  486. thlcgjvm(hlcg).a_load_loc_stack(current_asmdata.CurrAsmList,left.resultdef,left.location);
  487. end;
  488. (*
  489. procedure tjvminlinenode.second_sqrt_real;
  490. begin
  491. if (current_settings.cputype < cpu_PPC970) then
  492. internalerror(2007020910);
  493. location.loc:=LOC_FPUREGISTER;
  494. load_fpu_location;
  495. case left.location.size of
  496. OS_F32:
  497. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_FSQRTS,location.register,
  498. left.location.register));
  499. OS_F64:
  500. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_FSQRT,location.register,
  501. left.location.register));
  502. else
  503. inherited;
  504. end;
  505. end;
  506. *)
  507. procedure tjvminlinenode.second_sqr_real;
  508. begin
  509. load_fpu_location;
  510. location_reset(location,LOC_FPUREGISTER,location.size);
  511. location.register:=hlcg.getfpuregister(current_asmdata.CurrAsmList,resultdef);
  512. case left.location.size of
  513. OS_F32:
  514. begin
  515. current_asmdata.CurrAsmList.concat(taicpu.op_none(a_dup));
  516. thlcgjvm(hlcg).incstack(current_asmdata.CurrAsmList,1);
  517. current_asmdata.CurrAsmList.concat(taicpu.op_none(a_fmul));
  518. thlcgjvm(hlcg).decstack(current_asmdata.CurrAsmList,1);
  519. end;
  520. OS_F64:
  521. begin
  522. current_asmdata.CurrAsmList.concat(taicpu.op_none(a_dup2));
  523. thlcgjvm(hlcg).incstack(current_asmdata.CurrAsmList,2);
  524. current_asmdata.CurrAsmList.concat(taicpu.op_none(a_dmul));
  525. thlcgjvm(hlcg).decstack(current_asmdata.CurrAsmList,2);
  526. end;
  527. else
  528. internalerror(2011010804);
  529. end;
  530. thlcgjvm(hlcg).a_load_stack_reg(current_asmdata.CurrAsmList,resultdef,location.register);
  531. end;
  532. procedure tjvminlinenode.second_trunc_real;
  533. begin
  534. load_fpu_location;
  535. location_reset(location,LOC_REGISTER,left.location.size);
  536. location.register:=hlcg.getintregister(current_asmdata.CurrAsmList,resultdef);
  537. case left.location.size of
  538. OS_F32:
  539. begin
  540. current_asmdata.CurrAsmList.concat(taicpu.op_none(a_f2l));
  541. { 32 bit float -> 64 bit int: +1 stack slot }
  542. thlcgjvm(hlcg).incstack(current_asmdata.CurrAsmList,1);
  543. end;
  544. OS_F64:
  545. begin
  546. { 64 bit float -> 64 bit int: same number of stack slots }
  547. current_asmdata.CurrAsmList.concat(taicpu.op_none(a_d2l));
  548. end;
  549. else
  550. internalerror(2011010805);
  551. end;
  552. thlcgjvm(hlcg).a_load_stack_reg(current_asmdata.CurrAsmList,resultdef,location.register);
  553. end;
  554. procedure tjvminlinenode.second_new;
  555. var
  556. arr: tnode;
  557. hp: tcallparanode;
  558. paracount: longint;
  559. begin
  560. hp:=tcallparanode(left);
  561. { we don't second pass this one, it's only a type node }
  562. arr:=hp.left;
  563. if not is_dynamic_array(arr.resultdef) then
  564. internalerror(2011012204);
  565. hp:=tcallparanode(hp.right);
  566. if not assigned(hp) then
  567. internalerror(2011012205);
  568. paracount:=0;
  569. { put all the dimensions on the stack }
  570. repeat
  571. inc(paracount);
  572. secondpass(hp.left);
  573. thlcgjvm(hlcg).a_load_loc_stack(current_asmdata.CurrAsmList,hp.left.resultdef,hp.left.location);
  574. hp:=tcallparanode(hp.right);
  575. until not assigned(hp);
  576. { create the array }
  577. thlcgjvm(hlcg).g_newarray(current_asmdata.CurrAsmList,arr.resultdef,paracount);
  578. location_reset(location,LOC_REGISTER,OS_ADDR);
  579. location.register:=hlcg.getaddressregister(current_asmdata.CurrAsmList,resultdef);
  580. thlcgjvm(hlcg).a_load_stack_reg(current_asmdata.CurrAsmList,arr.resultdef,location.register);
  581. end;
  582. procedure tjvminlinenode.second_setlength;
  583. var
  584. target: tnode;
  585. lenpara: tnode;
  586. emptystr: ansichar;
  587. begin
  588. target:=tcallparanode(left).left;
  589. lenpara:=tcallparanode(tcallparanode(left).right).left;
  590. if assigned(tcallparanode(tcallparanode(left).right).right) or
  591. not is_constintnode(lenpara) or
  592. (tordconstnode(lenpara).value<>0) then
  593. internalerror(2011031801);
  594. secondpass(target);
  595. if is_wide_or_unicode_string(target.resultdef) then
  596. begin
  597. emptystr:=#0;
  598. current_asmdata.CurrAsmList.concat(taicpu.op_string(a_ldc,0,@emptystr));
  599. thlcgjvm(hlcg).incstack(current_asmdata.CurrAsmList,1);
  600. end
  601. else if is_dynamic_array(target.resultdef) then
  602. begin
  603. thlcgjvm(hlcg).a_load_const_stack(current_asmdata.CurrAsmList,s32inttype,0,R_INTREGISTER);
  604. thlcgjvm(hlcg).g_newarray(current_asmdata.CurrAsmList,target.resultdef,1);
  605. end
  606. {$ifndef nounsupported}
  607. else if left.resultdef.typ=stringdef then
  608. begin
  609. thlcgjvm(hlcg).a_load_const_stack(current_asmdata.CurrAsmList,java_jlobject,0,R_ADDRESSREGISTER);
  610. end
  611. {$endif}
  612. else
  613. internalerror(2011031401);
  614. thlcgjvm(hlcg).a_load_stack_loc(current_asmdata.CurrAsmList,target.resultdef,target.location);
  615. end;
  616. begin
  617. cinlinenode:=tjvminlinenode;
  618. end.